Auto merge of #25271 - tshepang:doc-deunwrap, r=steveklabnik
This commit is contained in:
@@ -137,7 +137,7 @@ pub trait Iterator {
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2, 3, 4, 5];
|
/// let a = [1, 2, 3, 4, 5];
|
||||||
/// assert_eq!(a.iter().last().unwrap(), &5);
|
/// assert_eq!(a.iter().last(), Some(&5));
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
@@ -155,7 +155,7 @@ pub trait Iterator {
|
|||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2, 3, 4, 5];
|
/// let a = [1, 2, 3, 4, 5];
|
||||||
/// let mut it = a.iter();
|
/// let mut it = a.iter();
|
||||||
/// assert_eq!(it.nth(2).unwrap(), &3);
|
/// assert_eq!(it.nth(2), Some(&3));
|
||||||
/// assert_eq!(it.nth(2), None);
|
/// assert_eq!(it.nth(2), None);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -178,8 +178,8 @@ pub trait Iterator {
|
|||||||
/// let a = [0];
|
/// let a = [0];
|
||||||
/// let b = [1];
|
/// let b = [1];
|
||||||
/// let mut it = a.iter().chain(b.iter());
|
/// let mut it = a.iter().chain(b.iter());
|
||||||
/// assert_eq!(it.next().unwrap(), &0);
|
/// assert_eq!(it.next(), Some(&0));
|
||||||
/// assert_eq!(it.next().unwrap(), &1);
|
/// assert_eq!(it.next(), Some(&1));
|
||||||
/// assert!(it.next().is_none());
|
/// assert!(it.next().is_none());
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -201,7 +201,7 @@ pub trait Iterator {
|
|||||||
/// let a = [0];
|
/// let a = [0];
|
||||||
/// let b = [1];
|
/// let b = [1];
|
||||||
/// let mut it = a.iter().zip(b.iter());
|
/// let mut it = a.iter().zip(b.iter());
|
||||||
/// assert_eq!(it.next().unwrap(), (&0, &1));
|
/// assert_eq!(it.next(), Some((&0, &1)));
|
||||||
/// assert!(it.next().is_none());
|
/// assert!(it.next().is_none());
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
@@ -234,8 +234,8 @@ pub trait Iterator {
|
|||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2];
|
/// let a = [1, 2];
|
||||||
/// let mut it = a.iter().map(|&x| 2 * x);
|
/// let mut it = a.iter().map(|&x| 2 * x);
|
||||||
/// assert_eq!(it.next().unwrap(), 2);
|
/// assert_eq!(it.next(), Some(2));
|
||||||
/// assert_eq!(it.next().unwrap(), 4);
|
/// assert_eq!(it.next(), Some(4));
|
||||||
/// assert!(it.next().is_none());
|
/// assert!(it.next().is_none());
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -255,7 +255,7 @@ pub trait Iterator {
|
|||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2];
|
/// let a = [1, 2];
|
||||||
/// let mut it = a.iter().filter(|&x| *x > 1);
|
/// let mut it = a.iter().filter(|&x| *x > 1);
|
||||||
/// assert_eq!(it.next().unwrap(), &2);
|
/// assert_eq!(it.next(), Some(&2));
|
||||||
/// assert!(it.next().is_none());
|
/// assert!(it.next().is_none());
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -275,7 +275,7 @@ pub trait Iterator {
|
|||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2];
|
/// let a = [1, 2];
|
||||||
/// let mut it = a.iter().filter_map(|&x| if x > 1 {Some(2 * x)} else {None});
|
/// let mut it = a.iter().filter_map(|&x| if x > 1 {Some(2 * x)} else {None});
|
||||||
/// assert_eq!(it.next().unwrap(), 4);
|
/// assert_eq!(it.next(), Some(4));
|
||||||
/// assert!(it.next().is_none());
|
/// assert!(it.next().is_none());
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -310,8 +310,8 @@ pub trait Iterator {
|
|||||||
/// ```
|
/// ```
|
||||||
/// let a = [100, 200];
|
/// let a = [100, 200];
|
||||||
/// let mut it = a.iter().enumerate();
|
/// let mut it = a.iter().enumerate();
|
||||||
/// assert_eq!(it.next().unwrap(), (0, &100));
|
/// assert_eq!(it.next(), Some((0, &100)));
|
||||||
/// assert_eq!(it.next().unwrap(), (1, &200));
|
/// assert_eq!(it.next(), Some((1, &200)));
|
||||||
/// assert!(it.next().is_none());
|
/// assert!(it.next().is_none());
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -353,9 +353,9 @@ pub trait Iterator {
|
|||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2, 3, 4, 5];
|
/// let a = [1, 2, 3, 4, 5];
|
||||||
/// let mut it = a.iter().skip_while(|&a| *a < 3);
|
/// let mut it = a.iter().skip_while(|&a| *a < 3);
|
||||||
/// assert_eq!(it.next().unwrap(), &3);
|
/// assert_eq!(it.next(), Some(&3));
|
||||||
/// assert_eq!(it.next().unwrap(), &4);
|
/// assert_eq!(it.next(), Some(&4));
|
||||||
/// assert_eq!(it.next().unwrap(), &5);
|
/// assert_eq!(it.next(), Some(&5));
|
||||||
/// assert!(it.next().is_none());
|
/// assert!(it.next().is_none());
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -375,8 +375,8 @@ pub trait Iterator {
|
|||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2, 3, 4, 5];
|
/// let a = [1, 2, 3, 4, 5];
|
||||||
/// let mut it = a.iter().take_while(|&a| *a < 3);
|
/// let mut it = a.iter().take_while(|&a| *a < 3);
|
||||||
/// assert_eq!(it.next().unwrap(), &1);
|
/// assert_eq!(it.next(), Some(&1));
|
||||||
/// assert_eq!(it.next().unwrap(), &2);
|
/// assert_eq!(it.next(), Some(&2));
|
||||||
/// assert!(it.next().is_none());
|
/// assert!(it.next().is_none());
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -395,8 +395,8 @@ pub trait Iterator {
|
|||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2, 3, 4, 5];
|
/// let a = [1, 2, 3, 4, 5];
|
||||||
/// let mut it = a.iter().skip(3);
|
/// let mut it = a.iter().skip(3);
|
||||||
/// assert_eq!(it.next().unwrap(), &4);
|
/// assert_eq!(it.next(), Some(&4));
|
||||||
/// assert_eq!(it.next().unwrap(), &5);
|
/// assert_eq!(it.next(), Some(&5));
|
||||||
/// assert!(it.next().is_none());
|
/// assert!(it.next().is_none());
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -413,9 +413,9 @@ pub trait Iterator {
|
|||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2, 3, 4, 5];
|
/// let a = [1, 2, 3, 4, 5];
|
||||||
/// let mut it = a.iter().take(3);
|
/// let mut it = a.iter().take(3);
|
||||||
/// assert_eq!(it.next().unwrap(), &1);
|
/// assert_eq!(it.next(), Some(&1));
|
||||||
/// assert_eq!(it.next().unwrap(), &2);
|
/// assert_eq!(it.next(), Some(&2));
|
||||||
/// assert_eq!(it.next().unwrap(), &3);
|
/// assert_eq!(it.next(), Some(&3));
|
||||||
/// assert!(it.next().is_none());
|
/// assert!(it.next().is_none());
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -437,11 +437,11 @@ pub trait Iterator {
|
|||||||
/// *fac = *fac * x;
|
/// *fac = *fac * x;
|
||||||
/// Some(*fac)
|
/// Some(*fac)
|
||||||
/// });
|
/// });
|
||||||
/// assert_eq!(it.next().unwrap(), 1);
|
/// assert_eq!(it.next(), Some(1));
|
||||||
/// assert_eq!(it.next().unwrap(), 2);
|
/// assert_eq!(it.next(), Some(2));
|
||||||
/// assert_eq!(it.next().unwrap(), 6);
|
/// assert_eq!(it.next(), Some(6));
|
||||||
/// assert_eq!(it.next().unwrap(), 24);
|
/// assert_eq!(it.next(), Some(24));
|
||||||
/// assert_eq!(it.next().unwrap(), 120);
|
/// assert_eq!(it.next(), Some(120));
|
||||||
/// assert!(it.next().is_none());
|
/// assert!(it.next().is_none());
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -680,7 +680,7 @@ pub trait Iterator {
|
|||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2, 3, 4, 5];
|
/// let a = [1, 2, 3, 4, 5];
|
||||||
/// let mut it = a.iter();
|
/// let mut it = a.iter();
|
||||||
/// assert_eq!(it.find(|&x| *x == 3).unwrap(), &3);
|
/// assert_eq!(it.find(|&x| *x == 3), Some(&3));
|
||||||
/// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
|
/// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
@@ -715,7 +715,7 @@ pub trait Iterator {
|
|||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2, 3, 4, 5];
|
/// let a = [1, 2, 3, 4, 5];
|
||||||
/// let mut it = a.iter();
|
/// let mut it = a.iter();
|
||||||
/// assert_eq!(it.position(|x| *x == 3).unwrap(), 2);
|
/// assert_eq!(it.position(|x| *x == 3), Some(2));
|
||||||
/// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
|
/// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
@@ -743,7 +743,7 @@ pub trait Iterator {
|
|||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2, 2, 4, 5];
|
/// let a = [1, 2, 2, 4, 5];
|
||||||
/// let mut it = a.iter();
|
/// let mut it = a.iter();
|
||||||
/// assert_eq!(it.rposition(|x| *x == 2).unwrap(), 2);
|
/// assert_eq!(it.rposition(|x| *x == 2), Some(2));
|
||||||
/// assert_eq!(it.collect::<Vec<_>>(), [&1, &2]);
|
/// assert_eq!(it.collect::<Vec<_>>(), [&1, &2]);
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
@@ -773,7 +773,7 @@ pub trait Iterator {
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2, 3, 4, 5];
|
/// let a = [1, 2, 3, 4, 5];
|
||||||
/// assert_eq!(a.iter().max().unwrap(), &5);
|
/// assert_eq!(a.iter().max(), Some(&5));
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
@@ -796,7 +796,7 @@ pub trait Iterator {
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2, 3, 4, 5];
|
/// let a = [1, 2, 3, 4, 5];
|
||||||
/// assert_eq!(a.iter().min().unwrap(), &1);
|
/// assert_eq!(a.iter().min(), Some(&1));
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
@@ -1025,9 +1025,9 @@ pub trait Iterator {
|
|||||||
/// ```
|
/// ```
|
||||||
/// let a = [1, 2];
|
/// let a = [1, 2];
|
||||||
/// let mut it = a.iter().cycle();
|
/// let mut it = a.iter().cycle();
|
||||||
/// assert_eq!(it.next().unwrap(), &1);
|
/// assert_eq!(it.next(), Some(&1));
|
||||||
/// assert_eq!(it.next().unwrap(), &2);
|
/// assert_eq!(it.next(), Some(&2));
|
||||||
/// assert_eq!(it.next().unwrap(), &1);
|
/// assert_eq!(it.next(), Some(&1));
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
Reference in New Issue
Block a user