1 use crate::ffi::{CStr, OsStr, OsString};
2 use crate::marker::PhantomData;
3 use crate::os::wasi::ffi::OsStrExt;
6 pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}
8 pub unsafe fn cleanup() {}
11 iter: vec::IntoIter<OsString>,
12 _dont_send_or_sync_me: PhantomData<*mut ()>,
15 /// Returns the command line arguments
16 pub fn args() -> Args {
18 iter: maybe_args().unwrap_or(Vec::new()).into_iter(),
19 _dont_send_or_sync_me: PhantomData,
23 fn maybe_args() -> Option<Vec<OsString>> {
25 let (argc, buf_size) = wasi::args_sizes_get().ok()?;
26 let mut argv = Vec::with_capacity(argc);
27 let mut buf = Vec::with_capacity(buf_size);
28 wasi::args_get(argv.as_mut_ptr(), buf.as_mut_ptr()).ok()?;
30 let mut ret = Vec::with_capacity(argc);
32 let s = CStr::from_ptr(ptr.cast());
33 ret.push(OsStr::from_bytes(s.to_bytes()).to_owned());
40 pub fn inner_debug(&self) -> &[OsString] {
45 impl Iterator for Args {
47 fn next(&mut self) -> Option<OsString> {
50 fn size_hint(&self) -> (usize, Option<usize>) {
55 impl ExactSizeIterator for Args {
56 fn len(&self) -> usize {
61 impl DoubleEndedIterator for Args {
62 fn next_back(&mut self) -> Option<OsString> {