Skip to content

Commit

Permalink
update args
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Aug 21, 2019
1 parent 4dee102 commit 88fd945
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/libstd/sys/wasi/args.rs
Expand Up @@ -18,8 +18,14 @@ pub struct Args {

/// 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())));
let buf = wasi::args_sizes_get().and_then(|args_sizes| {
let mut buf = Vec::with_capacity(args_sizes.get_count());
wasi::get_args(args_sizes, |arg| {
let arg = OsString::from_vec(arg.to_vec());
buf.push(arg);
})?;
Ok(buf)
}).unwrap_or(vec![]);
Args {
iter: buf.into_iter(),
_dont_send_or_sync_me: PhantomData
Expand Down

0 comments on commit 88fd945

Please sign in to comment.