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