Skip to content

Instantly share code, notes, and snippets.

@bitburnerz
Last active November 23, 2017 19:15
Show Gist options
  • Select an option

  • Save bitburnerz/8c227c37346fb7785e252cfc1ec3b8bc to your computer and use it in GitHub Desktop.

Select an option

Save bitburnerz/8c227c37346fb7785e252cfc1ec3b8bc to your computer and use it in GitHub Desktop.
fn main() {
let myvec: Vec<String> = vec!("string1".to_string(),
"string2".to_string(),
"string3".to_string(),
"string4".to_string(),
"string5".to_string(),
"string6".to_string(),
);
for vec_element in &myvec {
println!("{:?}", vec_element);
}
print_vector_by_value(myvec);
// print_vector_by_value(myvec); // this does not work since value has moved
// sized arrays can be moved
print_sized_array_by_value([1,2,3,4,5]);
}
fn print_vector_by_value(vectoprint: Vec<String>) {
println!("{:?}", vectoprint);
}
fn print_sized_array_by_value(sized_array_by_value_to_print: [u8; 5]) {
println!("{:?}", sized_array_by_value_to_print);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment