Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

不加vec!的话会有以下报错。 #467

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions solutions/collections/Vector.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ fn main() {
let v3 = Vec::from(s);
assert_eq!(v2, v3);

// 迭代器 Iterators 可以通过 collect 变成 Vec
let v4: Vec<i32> = vec![0; 10].into_iter().collect();
assert_eq!(v4, vec![0; 10]);

println!("Success!")
}
```
Expand Down
2 changes: 1 addition & 1 deletion zh-CN/src/collections/vector.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn main() {
assert_eq!(v2, v3);

// 迭代器 Iterators 可以通过 collect 变成 Vec
let v4: Vec<i32> = [0; 10].into_iter().collect();
let v4: Vec<i32> = vec![0; 10].into_iter().collect();
assert_eq!(v4, vec![0; 10]);

println!("Success!")
Expand Down