-
-
Save bitburnerz/8c227c37346fb7785e252cfc1ec3b8bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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