Skip to content

doc: "mut" not needed for the examples #32605

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

Merged
merged 1 commit into from
Mar 30, 2016
Merged
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
6 changes: 3 additions & 3 deletions src/doc/book/vectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ for i in v {
```

Note: You cannot use the vector again once you have iterated by taking ownership of the vector.
You can iterate the vector multiple times by taking a reference to the vector whilst iterating.
You can iterate the vector multiple times by taking a reference to the vector whilst iterating.
For example, the following code does not compile.

```rust,ignore
let mut v = vec![1, 2, 3, 4, 5];
let v = vec![1, 2, 3, 4, 5];

for i in v {
println!("Take ownership of the vector and its element {}", i);
Expand All @@ -134,7 +134,7 @@ for i in v {
Whereas the following works perfectly,

```rust
let mut v = vec![1, 2, 3, 4, 5];
let v = vec![1, 2, 3, 4, 5];

for i in &v {
println!("This is a reference to {}", i);
Expand Down