Skip to content

Commit

Permalink
Rollup merge of rust-lang#25271 - tshepang:doc-deunwrap, r=steveklabnik
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed May 10, 2015
2 parents 2802c3c + dcdc50d commit 253612d
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub trait Iterator {
///
/// ```
/// let a = [1, 2, 3, 4, 5];
/// assert_eq!(a.iter().last().unwrap(), &5);
/// assert_eq!(a.iter().last(), Some(&5));
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -155,7 +155,7 @@ pub trait Iterator {
/// ```
/// let a = [1, 2, 3, 4, 5];
/// 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);
/// ```
#[inline]
Expand All @@ -178,8 +178,8 @@ pub trait Iterator {
/// let a = [0];
/// let b = [1];
/// let mut it = a.iter().chain(b.iter());
/// assert_eq!(it.next().unwrap(), &0);
/// assert_eq!(it.next().unwrap(), &1);
/// assert_eq!(it.next(), Some(&0));
/// assert_eq!(it.next(), Some(&1));
/// assert!(it.next().is_none());
/// ```
#[inline]
Expand All @@ -201,7 +201,7 @@ pub trait Iterator {
/// let a = [0];
/// let b = [1];
/// 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());
/// ```
///
Expand Down Expand Up @@ -234,8 +234,8 @@ pub trait Iterator {
/// ```
/// let a = [1, 2];
/// let mut it = a.iter().map(|&x| 2 * x);
/// assert_eq!(it.next().unwrap(), 2);
/// assert_eq!(it.next().unwrap(), 4);
/// assert_eq!(it.next(), Some(2));
/// assert_eq!(it.next(), Some(4));
/// assert!(it.next().is_none());
/// ```
#[inline]
Expand All @@ -255,7 +255,7 @@ pub trait Iterator {
/// ```
/// let a = [1, 2];
/// 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());
/// ```
#[inline]
Expand All @@ -275,7 +275,7 @@ pub trait Iterator {
/// ```
/// let a = [1, 2];
/// 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());
/// ```
#[inline]
Expand Down Expand Up @@ -310,8 +310,8 @@ pub trait Iterator {
/// ```
/// let a = [100, 200];
/// let mut it = a.iter().enumerate();
/// assert_eq!(it.next().unwrap(), (0, &100));
/// assert_eq!(it.next().unwrap(), (1, &200));
/// assert_eq!(it.next(), Some((0, &100)));
/// assert_eq!(it.next(), Some((1, &200)));
/// assert!(it.next().is_none());
/// ```
#[inline]
Expand All @@ -329,12 +329,12 @@ pub trait Iterator {
/// # #![feature(core)]
/// let xs = [100, 200, 300];
/// let mut it = xs.iter().cloned().peekable();
/// assert_eq!(*it.peek().unwrap(), 100);
/// assert_eq!(it.next().unwrap(), 100);
/// assert_eq!(it.next().unwrap(), 200);
/// assert_eq!(*it.peek().unwrap(), 300);
/// assert_eq!(*it.peek().unwrap(), 300);
/// assert_eq!(it.next().unwrap(), 300);
/// assert_eq!(*it.peek(), Some(100));
/// assert_eq!(it.next(), Some(100));
/// assert_eq!(it.next(), Some(200));
/// assert_eq!(*it.peek(), Some(300));
/// assert_eq!(*it.peek(), Some(300));
/// assert_eq!(it.next(), Some(300));
/// assert!(it.peek().is_none());
/// assert!(it.next().is_none());
/// ```
Expand All @@ -353,9 +353,9 @@ pub trait Iterator {
/// ```
/// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter().skip_while(|&a| *a < 3);
/// assert_eq!(it.next().unwrap(), &3);
/// assert_eq!(it.next().unwrap(), &4);
/// assert_eq!(it.next().unwrap(), &5);
/// assert_eq!(it.next(), Some(&3));
/// assert_eq!(it.next(), Some(&4));
/// assert_eq!(it.next(), Some(&5));
/// assert!(it.next().is_none());
/// ```
#[inline]
Expand All @@ -375,8 +375,8 @@ pub trait Iterator {
/// ```
/// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter().take_while(|&a| *a < 3);
/// assert_eq!(it.next().unwrap(), &1);
/// assert_eq!(it.next().unwrap(), &2);
/// assert_eq!(it.next(), Some(&1));
/// assert_eq!(it.next(), Some(&2));
/// assert!(it.next().is_none());
/// ```
#[inline]
Expand All @@ -395,8 +395,8 @@ pub trait Iterator {
/// ```
/// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter().skip(3);
/// assert_eq!(it.next().unwrap(), &4);
/// assert_eq!(it.next().unwrap(), &5);
/// assert_eq!(it.next(), Some(&4));
/// assert_eq!(it.next(), Some(&5));
/// assert!(it.next().is_none());
/// ```
#[inline]
Expand All @@ -413,9 +413,9 @@ pub trait Iterator {
/// ```
/// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter().take(3);
/// assert_eq!(it.next().unwrap(), &1);
/// assert_eq!(it.next().unwrap(), &2);
/// assert_eq!(it.next().unwrap(), &3);
/// assert_eq!(it.next(), Some(&1));
/// assert_eq!(it.next(), Some(&2));
/// assert_eq!(it.next(), Some(&3));
/// assert!(it.next().is_none());
/// ```
#[inline]
Expand All @@ -437,11 +437,11 @@ pub trait Iterator {
/// *fac = *fac * x;
/// Some(*fac)
/// });
/// assert_eq!(it.next().unwrap(), 1);
/// assert_eq!(it.next().unwrap(), 2);
/// assert_eq!(it.next().unwrap(), 6);
/// assert_eq!(it.next().unwrap(), 24);
/// assert_eq!(it.next().unwrap(), 120);
/// assert_eq!(it.next(), Some(1));
/// assert_eq!(it.next(), Some(2));
/// assert_eq!(it.next(), Some(6));
/// assert_eq!(it.next(), Some(24));
/// assert_eq!(it.next(), Some(120));
/// assert!(it.next().is_none());
/// ```
#[inline]
Expand Down Expand Up @@ -680,7 +680,7 @@ pub trait Iterator {
/// ```
/// let a = [1, 2, 3, 4, 5];
/// 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]);
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -715,7 +715,7 @@ pub trait Iterator {
/// ```
/// let a = [1, 2, 3, 4, 5];
/// 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]);
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -743,7 +743,7 @@ pub trait Iterator {
/// ```
/// let a = [1, 2, 2, 4, 5];
/// 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]);
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -773,7 +773,7 @@ pub trait Iterator {
///
/// ```
/// let a = [1, 2, 3, 4, 5];
/// assert_eq!(a.iter().max().unwrap(), &5);
/// assert_eq!(a.iter().max(), Some(&5));
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -796,7 +796,7 @@ pub trait Iterator {
///
/// ```
/// let a = [1, 2, 3, 4, 5];
/// assert_eq!(a.iter().min().unwrap(), &1);
/// assert_eq!(a.iter().min(), Some(&1));
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -900,7 +900,7 @@ pub trait Iterator {
/// # #![feature(core)]
///
/// let a = [-3_i32, 0, 1, 5, -10];
/// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10);
/// assert_eq!(*a.iter().max_by(|x| x.abs()), Some(-10));
/// ```
#[inline]
#[unstable(feature = "core",
Expand Down Expand Up @@ -929,7 +929,7 @@ pub trait Iterator {
/// # #![feature(core)]
///
/// let a = [-3_i32, 0, 1, 5, -10];
/// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0);
/// assert_eq!(*a.iter().min_by(|x| x.abs()), Some(0));
/// ```
#[inline]
#[unstable(feature = "core",
Expand Down Expand Up @@ -1025,9 +1025,9 @@ pub trait Iterator {
/// ```
/// let a = [1, 2];
/// let mut it = a.iter().cycle();
/// assert_eq!(it.next().unwrap(), &1);
/// assert_eq!(it.next().unwrap(), &2);
/// assert_eq!(it.next().unwrap(), &1);
/// assert_eq!(it.next(), Some(&1));
/// assert_eq!(it.next(), Some(&2));
/// assert_eq!(it.next(), Some(&1));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down

0 comments on commit 253612d

Please sign in to comment.