Skip to content

Commit 69b18f7

Browse files
committed
Added more documentation
1 parent 1a04987 commit 69b18f7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

library/core/src/iter/traits/iterator.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,8 @@ pub trait Iterator {
17001700
///
17011701
/// # Examples
17021702
///
1703+
/// Basic usage:
1704+
///
17031705
/// ```
17041706
/// #![feature(iter_dedup)]
17051707
///
@@ -1713,6 +1715,15 @@ pub trait Iterator {
17131715
/// assert_eq!(iter.next(), Some(2));
17141716
/// assert_eq!(iter.next(), None);
17151717
/// ```
1718+
///
1719+
/// Example of an infinite loop:
1720+
///
1721+
/// ```no_run
1722+
/// #![feature(iter_dedup)]
1723+
///
1724+
/// // this will never terminate
1725+
/// let _ = std::iter::repeat(2).dedup().next();
1726+
/// ```
17161727
#[unstable(feature = "iter_dedup", reason = "recently added", issue = "83748")]
17171728
#[inline]
17181729
fn dedup(self) -> Dedup<Self, ByPartialEq, Self::Item>
@@ -1736,6 +1747,8 @@ pub trait Iterator {
17361747
///
17371748
/// # Examples
17381749
///
1750+
/// Basic usage:
1751+
///
17391752
/// ```
17401753
/// #![feature(iter_dedup)]
17411754
///
@@ -1749,6 +1762,15 @@ pub trait Iterator {
17491762
/// assert_eq!(iter.next(), Some("bar"));
17501763
/// assert_eq!(iter.next(), None);
17511764
/// ```
1765+
///
1766+
/// Example of an infinite loop:
1767+
///
1768+
/// ```no_run
1769+
/// #![feature(iter_dedup)]
1770+
///
1771+
/// // this will never terminate
1772+
/// let _ = std::iter::repeat(2).dedup_by(|a, b| a == b).next();
1773+
/// ```
17521774
#[unstable(feature = "iter_dedup", reason = "recently added", issue = "83748")]
17531775
#[inline]
17541776
fn dedup_by<F>(self, same_bucket: F) -> Dedup<Self, F, Self::Item>
@@ -1769,6 +1791,8 @@ pub trait Iterator {
17691791
///
17701792
/// # Examples
17711793
///
1794+
/// Basic usage:
1795+
///
17721796
/// ```
17731797
/// #![feature(iter_dedup)]
17741798
///
@@ -1782,6 +1806,15 @@ pub trait Iterator {
17821806
/// assert_eq!(iter.next(), Some(20));
17831807
/// assert_eq!(iter.next(), None);
17841808
/// ```
1809+
///
1810+
/// Example of an infinite loop:
1811+
///
1812+
/// ```no_run
1813+
/// #![feature(iter_dedup)]
1814+
///
1815+
/// // this will never terminate
1816+
/// let _ = std::iter::repeat(2).dedup_by_key(|&n| n).next();
1817+
/// ```
17851818
#[unstable(feature = "iter_dedup", reason = "recently added", issue = "83748")]
17861819
#[inline]
17871820
fn dedup_by_key<F, K>(self, key: F) -> Dedup<Self, ByKey<F>, Self::Item>

0 commit comments

Comments
 (0)