From 6990f89c167f96b2fb3f4fdf1344551b638c8fe7 Mon Sep 17 00:00:00 2001 From: Scott Rhodes <38151815+Scott169@users.noreply.github.com> Date: Sun, 12 Nov 2023 13:45:22 -0500 Subject: [PATCH] Correction of problem 1 in vector.md ```v1``` cannot be referred if the ownership of ```v``` is moved to ```fn is_vec(v: &Vec)``` --- en/src/collections/vector.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/en/src/collections/vector.md b/en/src/collections/vector.md index 1c30ec3..63a2594 100644 --- a/en/src/collections/vector.md +++ b/en/src/collections/vector.md @@ -9,26 +9,26 @@ fn main() { let arr: [u8; 3] = [1, 2, 3]; let v = Vec::from(arr); - is_vec(v); + is_vec(&v); let v = vec![1, 2, 3]; - is_vec(v); + is_vec(&v); // vec!(..) and vec![..] are same macros, so let v = vec!(1, 2, 3); - is_vec(v); + is_vec(&v); // In code below, v is Vec<[u8; 3]> , not Vec // USE Vec::new and `for` to rewrite the below code let v1 = vec!(arr); - is_vec(v1); + is_vec(&v1); assert_eq!(v, v1); println!("Success!"); } -fn is_vec(v: Vec) {} +fn is_vec(v: &Vec) {} ``` @@ -241,4 +241,4 @@ fn main() { ip.display(); } } -``` \ No newline at end of file +```