@@ -505,13 +505,14 @@ pub trait Itertools: Iterator {
505
505
intersperse:: intersperse_with ( self , element)
506
506
}
507
507
508
- /// Returns an element at a specific location, or returns an iterator
509
- /// over a subsection of the iterator.
508
+ /// Returns an iterator over a subsection of the iterator.
510
509
///
511
510
/// Works similarly to [`slice::get`](https://doc.rust-lang.org/std/primitive.slice.html#method.get).
512
511
///
513
- /// It's a generalisation of [`take`], [`skip`] and [`nth`], and uses these
514
- /// under the hood.
512
+ /// It's a generalisation of [`Iterator::take`] and [`Iterator::skip`],
513
+ /// and uses these under the hood.
514
+ /// Therefore, the resulting iterator is [`DoubleEndedIterator`]
515
+ /// and/or [`ExactSizeIterator`] if the adapted iterator is.
515
516
///
516
517
/// # Unspecified Behavior
517
518
/// The result of indexing with an exhausted [`core::ops::RangeInclusive`] is unspecified.
@@ -524,7 +525,7 @@ pub trait Itertools: Iterator {
524
525
/// let vec = vec![3, 1, 4, 1, 5];
525
526
///
526
527
/// let mut range: Vec<_> =
527
- /// vec.iter().get(1..=3).copied().collect();
528
+ /// vec.iter().get(1..=3).copied().collect();
528
529
/// assert_eq!(&range, &[1, 4, 1]);
529
530
///
530
531
/// // It works with other types of ranges, too
@@ -537,13 +538,12 @@ pub trait Itertools: Iterator {
537
538
/// range = vec.iter().get(2..).copied().collect();
538
539
/// assert_eq!(&range, &[4, 1, 5]);
539
540
///
541
+ /// range = vec.iter().get(..=2).copied().collect();
542
+ /// assert_eq!(&range, &[3, 1, 4]);
543
+ ///
540
544
/// range = vec.iter().get(..).copied().collect();
541
545
/// assert_eq!(range, vec);
542
546
/// ```
543
- ///
544
- /// [`take`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.take
545
- /// [`skip`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.skip
546
- /// [`nth`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.nth
547
547
fn get < R > ( self , index : R ) -> R :: Output
548
548
where
549
549
Self : Sized ,
0 commit comments