@@ -192,15 +192,15 @@ let mut it = xs.iter().zip(ys.iter());
192
192
193
193
// print out the pairs of elements up to (&3, &"baz")
194
194
for it.advance |(x, y)| {
195
- println(fmt !("%d %s", * x, * y) );
195
+ printfln !("%d %s", * x, * y);
196
196
197
197
if *x == 3 {
198
198
break;
199
199
}
200
200
}
201
201
202
202
// yield and print the last pair from the iterator
203
- println(fmt !("last: %?", it.next() ));
203
+ printfln !("last: %?", it.next());
204
204
205
205
// the iterator is now fully consumed
206
206
assert!(it.next().is_none());
@@ -294,15 +294,31 @@ another `DoubleEndedIterator` with `next` and `next_back` exchanged.
294
294
~~~
295
295
let xs = [ 1, 2, 3, 4, 5, 6] ;
296
296
let mut it = xs.iter();
297
- println(fmt !("%?", it.next() )); // prints ` Some(&1) `
298
- println(fmt !("%?", it.next() )); // prints ` Some(&2) `
299
- println(fmt !("%?", it.next_back() )); // prints ` Some(&6) `
297
+ printfln !("%?", it.next()); // prints ` Some(&1) `
298
+ printfln !("%?", it.next()); // prints ` Some(&2) `
299
+ printfln !("%?", it.next_back()); // prints ` Some(&6) `
300
300
301
301
// prints ` 5 ` , ` 4 ` and ` 3 `
302
302
for it.invert().advance |&x| {
303
- println(fmt !("%?", x) )
303
+ printfln !("%?", x)
304
304
}
305
305
~~~
306
306
307
307
The `rev_iter` and `mut_rev_iter` methods on vectors just return an inverted
308
308
version of the standard immutable and mutable vector iterators.
309
+
310
+ The `chain_`, `transform`, `filter`, `filter_map` and `peek` adaptors are
311
+ `DoubleEndedIterator` implementations if the underlying iterators are.
312
+
313
+ ~~~
314
+ let xs = [ 1, 2, 3, 4] ;
315
+ let ys = [ 5, 6, 7, 8] ;
316
+ let mut it = xs.iter().chain_ (ys.iter()).transform(|&x| x * 2);
317
+
318
+ printfln!("%?", it.next()); // prints ` Some(2) `
319
+
320
+ // prints ` 16 ` , ` 14 ` , ` 12 ` , ` 10 ` , ` 8 ` , ` 6 ` , ` 4 `
321
+ for it.invert().advance |x| {
322
+ printfln!("%?", x);
323
+ }
324
+ ~~~
0 commit comments