Skip to content

Commit

Permalink
use new get_args
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Aug 20, 2019
1 parent 7daf890 commit 4dee102
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/libstd/sys/wasi/args.rs
Expand Up @@ -12,14 +12,16 @@ pub unsafe fn cleanup() {
}

pub struct Args {
iter: vec::IntoIter<Vec<u8>>,
iter: vec::IntoIter<OsString>,
_dont_send_or_sync_me: PhantomData<*mut ()>,
}

/// Returns the command line arguments
pub fn args() -> Args {
let mut buf = Vec::new();
let _ = wasi::get_args(|arg| buf.push(OsString::from_vec(arg.to_vec())));
Args {
iter: wasi::get_args().unwrap_or(Vec::new()).into_iter(),
iter: buf.into_iter(),
_dont_send_or_sync_me: PhantomData
}
}
Expand All @@ -33,7 +35,7 @@ impl Args {
impl Iterator for Args {
type Item = OsString;
fn next(&mut self) -> Option<OsString> {
self.iter.next().map(OsString::from_vec)
self.iter.next()
}
fn size_hint(&self) -> (usize, Option<usize>) {
self.iter.size_hint()
Expand Down

0 comments on commit 4dee102

Please sign in to comment.