Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let my_arr_a: [usize; 5] = [1,2,3,4,5];
- let my_arr_b: [usize; 5] = my_arr_a; // Since `usize` implements `Copy`, the containing array implements `Copy` so we don't need to clone it and the value will automatically be copied
- println!("v {}", my_arr_a[0]);
- let my_arr_a: [String; 3] = ["abc".to_owned(), "def".to_owned(), "hij".to_owned()];
- let my_arr_b: [String; 3] = my_arr_a.clone(); // Since `String` does not implement `Copy` but does implement `Clone`, we need to call `Clone` on the containing array; otherwise we're moving the value
- println!("v {}", my_arr_a[0]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement