diff --git a/solutions/collections/Vector.md b/solutions/collections/Vector.md index 7581a802..df57be3a 100644 --- a/solutions/collections/Vector.md +++ b/solutions/collections/Vector.md @@ -104,6 +104,10 @@ fn main() { let v3 = Vec::from(s); assert_eq!(v2, v3); + // 迭代器 Iterators 可以通过 collect 变成 Vec + let v4: Vec = vec![0; 10].into_iter().collect(); + assert_eq!(v4, vec![0; 10]); + println!("Success!") } ``` diff --git a/zh-CN/src/collections/vector.md b/zh-CN/src/collections/vector.md index f2a833a1..67d7a2e0 100644 --- a/zh-CN/src/collections/vector.md +++ b/zh-CN/src/collections/vector.md @@ -83,7 +83,7 @@ fn main() { assert_eq!(v2, v3); // 迭代器 Iterators 可以通过 collect 变成 Vec - let v4: Vec = [0; 10].into_iter().collect(); + let v4: Vec = vec![0; 10].into_iter().collect(); assert_eq!(v4, vec![0; 10]); println!("Success!")