Skip to content

Instantly share code, notes, and snippets.

@cgwalters
Forked from rust-play/playground.rs
Created June 10, 2018 12:59
Show Gist options
  • Save cgwalters/3f32fe21fc411b24d10a6faff61bf7fe to your computer and use it in GitHub Desktop.
Save cgwalters/3f32fe21fc411b24d10a6faff61bf7fe to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
fn f<T: AsRef<str>>(args: &[T])
{
let bargv = &["foo", "bar"];
let nargv : Vec<&str> = bargv.iter().map(|&v|v).chain(args.iter().map(AsRef::as_ref)).collect();
println!("{:?}", nargv);
}
fn main() {
let args : Vec<String> = std::env::args().collect();
f(&args);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment