@@ -112,10 +112,10 @@ iterator object. For example, vector slices several iterators available:
112
112
113
113
* `iter()` and `rev_iter()`, for immutable references to the elements
114
114
* `mut_iter()` and `mut_rev_iter()`, for mutable references to the elements
115
- * `consume_iter ()` and `consume_rev_iter `, to move the elements out by-value
115
+ * `move_iter ()` and `move_rev_iter `, to move the elements out by-value
116
116
117
117
A typical mutable container will implement at least `iter()`, `mut_iter()` and
118
- `consume_iter ()` along with the reverse variants if it maintains an order.
118
+ `move_iter ()` along with the reverse variants if it maintains an order.
119
119
120
120
### Freezing
121
121
@@ -139,9 +139,9 @@ and `&mut`.
139
139
140
140
## Iterator adaptors
141
141
142
- The `IteratorUtil ` trait implements common algorithms as methods extending
143
- every `Iterator` implementation. For example, the `fold` method will accumulate
144
- the items yielded by an `Iterator` into a single value:
142
+ The `Iterator ` trait provides many common algorithms as default methods. For
143
+ example, the `fold` method will accumulate the items yielded by an `Iterator`
144
+ into a single value:
145
145
146
146
~~~
147
147
let xs = [ 1, 9, 2, 3, 14, 12] ;
@@ -154,14 +154,10 @@ Some adaptors return an adaptor object implementing the `Iterator` trait itself:
154
154
~~~
155
155
let xs = [ 1, 9, 2, 3, 14, 12] ;
156
156
let ys = [ 5, 2, 1, 8] ;
157
- let sum = xs.iter().chain _ (ys.iter()).fold(0, |a, b| a + * b);
157
+ let sum = xs.iter().chain (ys.iter()).fold(0, |a, b| a + * b);
158
158
assert_eq!(sum, 57);
159
159
~~~
160
160
161
- Note that some adaptors like the `chain_` method above use a trailing
162
- underscore to work around an issue with method resolve. The underscores will be
163
- dropped when they become unnecessary.
164
-
165
161
## For loops
166
162
167
163
The `for` keyword can be used as sugar for iterating through any iterator:
@@ -212,7 +208,7 @@ Iterators offer generic conversion to containers with the `collect` adaptor:
212
208
213
209
~~~
214
210
let xs = [ 0, 1, 1, 2, 3, 5, 8] ;
215
- let ys = xs.rev_iter().skip(1).transform (|&x| x * 2).collect::<~ [ int] >();
211
+ let ys = xs.rev_iter().skip(1).map (|&x| x * 2).collect::<~ [ int] >();
216
212
assert_eq!(ys, ~ [ 10, 6, 4, 2, 2, 0] );
217
213
~~~
218
214
@@ -307,13 +303,13 @@ for &x in it.invert() {
307
303
The `rev_iter` and `mut_rev_iter` methods on vectors just return an inverted
308
304
version of the standard immutable and mutable vector iterators.
309
305
310
- The `chain_ `, `transform `, `filter`, `filter_map` and `peek ` adaptors are
306
+ The `chain `, `map `, `filter`, `filter_map` and `inspect ` adaptors are
311
307
`DoubleEndedIterator` implementations if the underlying iterators are.
312
308
313
309
~~~
314
310
let xs = [ 1, 2, 3, 4] ;
315
311
let ys = [ 5, 6, 7, 8] ;
316
- let mut it = xs.iter().chain _ (ys.iter()).transform (|&x| x * 2);
312
+ let mut it = xs.iter().chain (ys.iter()).map (|&x| x * 2);
317
313
318
314
printfln!("%?", it.next()); // prints ` Some(2) `
319
315
@@ -329,13 +325,13 @@ The `RandomAccessIterator` trait represents an iterator offering random access
329
325
to the whole range. The `indexable` method retrieves the number of elements
330
326
accessible with the `idx` method.
331
327
332
- The `chain_ ` adaptor is an implementation of `RandomAccessIterator` if the
328
+ The `chain ` adaptor is an implementation of `RandomAccessIterator` if the
333
329
underlying iterators are.
334
330
335
331
~~~
336
332
let xs = [ 1, 2, 3, 4, 5] ;
337
333
let ys = ~ [ 7, 9, 11] ;
338
- let mut it = xs.iter().chain _ (ys.iter());
334
+ let mut it = xs.iter().chain (ys.iter());
339
335
printfln!("%?", it.idx(0)); // prints ` Some(&1) `
340
336
printfln!("%?", it.idx(5)); // prints ` Some(&7) `
341
337
printfln!("%?", it.idx(7)); // prints ` Some(&11) `
0 commit comments