1
1
# SOME DESCRIPTIVE TITLE
2
- # Copyright (C) YEAR Free Software Foundation, Inc.
3
- # This file is distributed under the same license as the PACKAGE package.
2
+ # Copyright (C) YEAR The Rust Project Developers
3
+ # This file is distributed under the same license as the Rust package.
4
4
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
5
#
6
6
#, fuzzy
7
7
msgid ""
8
8
msgstr ""
9
- "Project-Id-Version : PACKAGE VERSION \n "
10
- "POT-Creation-Date : 2013-07-07 21:10+0300 \n "
9
+ "Project-Id-Version : Rust 0.8-pre \n "
10
+ "POT-Creation-Date : 2013-07-17 07:18+0900 \n "
11
11
"PO-Revision-Date : YEAR-MO-DA HO:MI+ZONE\n "
12
12
"Last-Translator : FULL NAME <EMAIL@ADDRESS>\n "
13
13
"
Language-Team :
LANGUAGE <[email protected] >\n "
@@ -195,7 +195,7 @@ msgid ""
195
195
msgstr ""
196
196
197
197
#. type: Plain text
198
- #: doc/tutorial-container.md:89
198
+ #: doc/tutorial-container.md:89 doc/tutorial-container.md:262
199
199
#, no-wrap
200
200
msgid ""
201
201
"~~~\n"
@@ -217,7 +217,7 @@ msgid ""
217
217
msgstr ""
218
218
219
219
#. type: Plain text
220
- #: doc/tutorial-container.md:107
220
+ #: doc/tutorial-container.md:107 doc/tutorial-container.md:284
221
221
#, no-wrap
222
222
msgid ""
223
223
"impl Iterator<int> for ZeroStream {\n"
@@ -440,6 +440,162 @@ msgid ""
440
440
msgstr ""
441
441
442
442
#. type: Plain text
443
- #: doc/tutorial-container.md:207
443
+ #: doc/tutorial-container.md:208
444
444
msgid "// the iterator is now fully consumed assert!(it.next().is_none()); ~~~"
445
445
msgstr ""
446
+
447
+ #. type: Plain text
448
+ #: doc/tutorial-container.md:210
449
+ msgid "## Conversion"
450
+ msgstr ""
451
+
452
+ #. type: Plain text
453
+ #: doc/tutorial-container.md:212
454
+ msgid ""
455
+ "Iterators offer generic conversion to containers with the `collect` adaptor:"
456
+ msgstr ""
457
+
458
+ #. type: Plain text
459
+ #: doc/tutorial-container.md:218
460
+ msgid ""
461
+ "~~~ let xs = [0, 1, 1, 2, 3, 5, 8]; let ys = xs.rev_iter().skip(1)."
462
+ "transform(|&x| x * 2).collect::<~[int]>(); assert_eq!(ys, ~[10, 6, 4, 2, 2, "
463
+ "0]); ~~~"
464
+ msgstr ""
465
+
466
+ #. type: Plain text
467
+ #: doc/tutorial-container.md:221
468
+ msgid ""
469
+ "The method requires a type hint for the container type, if the surrounding "
470
+ "code does not provide sufficient information."
471
+ msgstr ""
472
+
473
+ #. type: Plain text
474
+ #: doc/tutorial-container.md:225
475
+ msgid ""
476
+ "Containers can provide conversion from iterators through `collect` by "
477
+ "implementing the `FromIterator` trait. For example, the implementation for "
478
+ "vectors is as follows:"
479
+ msgstr ""
480
+
481
+ #. type: Plain text
482
+ #: doc/tutorial-container.md:238
483
+ #, no-wrap
484
+ msgid ""
485
+ "~~~\n"
486
+ "impl<A, T: Iterator<A>> FromIterator<A, T> for ~[A] {\n"
487
+ " pub fn from_iterator(iterator: &mut T) -> ~[A] {\n"
488
+ " let (lower, _) = iterator.size_hint();\n"
489
+ " let mut xs = with_capacity(lower);\n"
490
+ " for iterator.advance |x| {\n"
491
+ " xs.push(x);\n"
492
+ " }\n"
493
+ " xs\n"
494
+ " }\n"
495
+ "}\n"
496
+ "~~~\n"
497
+ msgstr ""
498
+
499
+ #. type: Plain text
500
+ #: doc/tutorial-container.md:240
501
+ msgid "### Size hints"
502
+ msgstr ""
503
+
504
+ #. type: Plain text
505
+ #: doc/tutorial-container.md:243
506
+ msgid ""
507
+ "The `Iterator` trait provides a `size_hint` default method, returning a "
508
+ "lower bound and optionally on upper bound on the length of the iterator:"
509
+ msgstr ""
510
+
511
+ #. type: Plain text
512
+ #: doc/tutorial-container.md:247
513
+ msgid "~~~ fn size_hint(&self) -> (uint, Option<uint>) { (0, None) } ~~~"
514
+ msgstr ""
515
+
516
+ #. type: Plain text
517
+ #: doc/tutorial-container.md:251
518
+ msgid ""
519
+ "The vector implementation of `FromIterator` from above uses the lower bound "
520
+ "to pre-allocate enough space to hold the minimum number of elements the "
521
+ "iterator will yield."
522
+ msgstr ""
523
+
524
+ #. type: Plain text
525
+ #: doc/tutorial-container.md:254
526
+ msgid ""
527
+ "The default implementation is always correct, but it should be overridden if "
528
+ "the iterator can provide better information."
529
+ msgstr ""
530
+
531
+ #. type: Plain text
532
+ #: doc/tutorial-container.md:256
533
+ msgid ""
534
+ "The `ZeroStream` from earlier can provide an exact lower and upper bound:"
535
+ msgstr ""
536
+
537
+ #. type: Plain text
538
+ #: doc/tutorial-container.md:267
539
+ #, no-wrap
540
+ msgid ""
541
+ "impl ZeroStream {\n"
542
+ " fn new(n: uint) -> ZeroStream {\n"
543
+ " ZeroStream { remaining: n }\n"
544
+ " }\n"
545
+ msgstr ""
546
+
547
+ #. type: Plain text
548
+ #: doc/tutorial-container.md:272
549
+ #, no-wrap
550
+ msgid ""
551
+ " fn size_hint(&self) -> (uint, Option<uint>) {\n"
552
+ " (self.remaining, Some(self.remaining))\n"
553
+ " }\n"
554
+ "}\n"
555
+ msgstr ""
556
+
557
+ #. type: Plain text
558
+ #: doc/tutorial-container.md:286
559
+ msgid "## Double-ended iterators"
560
+ msgstr ""
561
+
562
+ #. type: Plain text
563
+ #: doc/tutorial-container.md:290
564
+ msgid ""
565
+ "The `DoubleEndedIterator` trait represents an iterator able to yield "
566
+ "elements from either end of a range. It inherits from the `Iterator` trait "
567
+ "and extends it with the `next_back` function."
568
+ msgstr ""
569
+
570
+ #. type: Plain text
571
+ #: doc/tutorial-container.md:293
572
+ msgid ""
573
+ "A `DoubleEndedIterator` can be flipped with the `invert` adaptor, returning "
574
+ "another `DoubleEndedIterator` with `next` and `next_back` exchanged."
575
+ msgstr ""
576
+
577
+ #. type: Plain text
578
+ #: doc/tutorial-container.md:300
579
+ msgid ""
580
+ "~~~ let xs = [1, 2, 3, 4, 5, 6]; let mut it = xs.iter(); println(fmt!(\" %?"
581
+ "\" , it.next())); // prints `Some(&1)` println(fmt!(\" %?\" , it.next())); // "
582
+ "prints `Some(&2)` println(fmt!(\" %?\" , it.next_back())); // prints `Some(&6)`"
583
+ msgstr ""
584
+
585
+ #. type: Plain text
586
+ #: doc/tutorial-container.md:306
587
+ #, no-wrap
588
+ msgid ""
589
+ "// prints `5`, `4` and `3`\n"
590
+ "for it.invert().advance |&x| {\n"
591
+ " println(fmt!(\" %?\" , x))\n"
592
+ "}\n"
593
+ "~~~\n"
594
+ msgstr ""
595
+
596
+ #. type: Plain text
597
+ #: doc/tutorial-container.md:308
598
+ msgid ""
599
+ "The `rev_iter` and `mut_rev_iter` methods on vectors just return an inverted "
600
+ "version of the standard immutable and mutable vector iterators."
601
+ msgstr ""
0 commit comments