mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Suggest mut_iter and move_iter when iterating over vectors, as well as iter.
+3
-1
@@ -71,11 +71,13 @@ Use the [`iter`](http://static.rust-lang.org/doc/master/std/vec/trait.ImmutableV
|
||||
|
||||
```rust
|
||||
let values: ~[int] = ~[1, 2, 3, 4, 5];
|
||||
for value in values.iter() {
|
||||
for value in values.iter() { // value: &int
|
||||
println(value.to_str());
|
||||
}
|
||||
```
|
||||
|
||||
(See also [`mut_iter`](http://static.rust-lang.org/doc/master/std/vec/trait.MutableVector.html#tymethod.mut_iter) which yields `&mut int` and [`move_iter`](http://static.rust-lang.org/doc/master/std/vec/trait.OwnedVector.html#tymethod.move_iter) which yields `int` while consuming the `values` vector.)
|
||||
|
||||
# Contributing to this page
|
||||
|
||||
For small examples, have full type annotations, as much as is reasonable, to keep it clear what, exactly, everything is doing. Try to link to the API docs, as well.
|
||||
|
||||
Reference in New Issue
Block a user