Fixed uses of get() to unwrap() in doc examples in std::iter
This commit is contained in:
parent
b4197aeed6
commit
2839805b9c
@ -115,8 +115,8 @@ fn size_hint(&self) -> (uint, Option<uint>) { (0, None) }
|
||||
/// let a = [0];
|
||||
/// let b = [1];
|
||||
/// let mut it = a.iter().chain(b.iter());
|
||||
/// assert_eq!(it.next().get(), &0);
|
||||
/// assert_eq!(it.next().get(), &1);
|
||||
/// assert_eq!(it.next().unwrap(), &0);
|
||||
/// assert_eq!(it.next().unwrap(), &1);
|
||||
/// assert!(it.next().is_none());
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -135,7 +135,7 @@ fn chain<U: Iterator<A>>(self, other: U) -> Chain<Self, U> {
|
||||
/// let a = [0];
|
||||
/// let b = [1];
|
||||
/// let mut it = a.iter().zip(b.iter());
|
||||
/// assert_eq!(it.next().get(), (&0, &1));
|
||||
/// assert_eq!(it.next().unwrap(), (&0, &1));
|
||||
/// assert!(it.next().is_none());
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -151,8 +151,8 @@ fn zip<B, U: Iterator<B>>(self, other: U) -> Zip<Self, U> {
|
||||
/// ```rust
|
||||
/// let a = [1, 2];
|
||||
/// let mut it = a.iter().map(|&x| 2 * x);
|
||||
/// assert_eq!(it.next().get(), 2);
|
||||
/// assert_eq!(it.next().get(), 4);
|
||||
/// assert_eq!(it.next().unwrap(), 2);
|
||||
/// assert_eq!(it.next().unwrap(), 4);
|
||||
/// assert!(it.next().is_none());
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -169,7 +169,7 @@ fn map<'r, B>(self, f: &'r fn(A) -> B) -> Map<'r, A, B, Self> {
|
||||
/// ```rust
|
||||
/// let a = [1, 2];
|
||||
/// let mut it = a.iter().filter(|&x| *x > 1);
|
||||
/// assert_eq!(it.next().get(), &2);
|
||||
/// assert_eq!(it.next().unwrap(), &2);
|
||||
/// assert!(it.next().is_none());
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -186,7 +186,7 @@ fn filter<'r>(self, predicate: &'r fn(&A) -> bool) -> Filter<'r, A, Self> {
|
||||
/// ```rust
|
||||
/// let a = [1, 2];
|
||||
/// let mut it = a.iter().filter_map(|&x| if x > 1 {Some(2 * x)} else {None});
|
||||
/// assert_eq!(it.next().get(), 4);
|
||||
/// assert_eq!(it.next().unwrap(), 4);
|
||||
/// assert!(it.next().is_none());
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -202,8 +202,8 @@ fn filter_map<'r, B>(self, f: &'r fn(A) -> Option<B>) -> FilterMap<'r, A, B, Sel
|
||||
/// ```rust
|
||||
/// let a = [100, 200];
|
||||
/// let mut it = a.iter().enumerate();
|
||||
/// assert_eq!(it.next().get(), (0, &100));
|
||||
/// assert_eq!(it.next().get(), (1, &200));
|
||||
/// assert_eq!(it.next().unwrap(), (0, &100));
|
||||
/// assert_eq!(it.next().unwrap(), (1, &200));
|
||||
/// assert!(it.next().is_none());
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -243,9 +243,9 @@ fn peekable(self) -> Peekable<A, Self> {
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 2, 1];
|
||||
/// let mut it = a.iter().skip_while(|&a| *a < 3);
|
||||
/// assert_eq!(it.next().get(), &3);
|
||||
/// assert_eq!(it.next().get(), &2);
|
||||
/// assert_eq!(it.next().get(), &1);
|
||||
/// assert_eq!(it.next().unwrap(), &3);
|
||||
/// assert_eq!(it.next().unwrap(), &2);
|
||||
/// assert_eq!(it.next().unwrap(), &1);
|
||||
/// assert!(it.next().is_none());
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -262,8 +262,8 @@ fn skip_while<'r>(self, predicate: &'r fn(&A) -> bool) -> SkipWhile<'r, A, Self>
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 2, 1];
|
||||
/// let mut it = a.iter().take_while(|&a| *a < 3);
|
||||
/// assert_eq!(it.next().get(), &1);
|
||||
/// assert_eq!(it.next().get(), &2);
|
||||
/// assert_eq!(it.next().unwrap(), &1);
|
||||
/// assert_eq!(it.next().unwrap(), &2);
|
||||
/// assert!(it.next().is_none());
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -279,8 +279,8 @@ fn take_while<'r>(self, predicate: &'r fn(&A) -> bool) -> TakeWhile<'r, A, Self>
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter().skip(3);
|
||||
/// assert_eq!(it.next().get(), &4);
|
||||
/// assert_eq!(it.next().get(), &5);
|
||||
/// assert_eq!(it.next().unwrap(), &4);
|
||||
/// assert_eq!(it.next().unwrap(), &5);
|
||||
/// assert!(it.next().is_none());
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -296,9 +296,9 @@ fn skip(self, n: uint) -> Skip<Self> {
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter().take(3);
|
||||
/// assert_eq!(it.next().get(), &1);
|
||||
/// assert_eq!(it.next().get(), &2);
|
||||
/// assert_eq!(it.next().get(), &3);
|
||||
/// assert_eq!(it.next().unwrap(), &1);
|
||||
/// assert_eq!(it.next().unwrap(), &2);
|
||||
/// assert_eq!(it.next().unwrap(), &3);
|
||||
/// assert!(it.next().is_none());
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -319,11 +319,11 @@ fn take(self, n: uint) -> Take<Self> {
|
||||
/// *fac = *fac * x;
|
||||
/// Some(*fac)
|
||||
/// });
|
||||
/// assert_eq!(it.next().get(), 1);
|
||||
/// assert_eq!(it.next().get(), 2);
|
||||
/// assert_eq!(it.next().get(), 6);
|
||||
/// assert_eq!(it.next().get(), 24);
|
||||
/// assert_eq!(it.next().get(), 120);
|
||||
/// 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!(it.next().is_none());
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -485,7 +485,7 @@ fn to_owned_vec(&mut self) -> ~[A] {
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// let mut it = a.iter();
|
||||
/// assert!(it.nth(2).get() == &3);
|
||||
/// assert!(it.nth(2).unwrap() == &3);
|
||||
/// assert!(it.nth(2) == None);
|
||||
/// ```
|
||||
#[inline]
|
||||
@ -506,7 +506,7 @@ fn nth(&mut self, mut n: uint) -> Option<A> {
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// assert!(a.iter().last().get() == &5);
|
||||
/// assert!(a.iter().last().unwrap() == &5);
|
||||
/// ```
|
||||
#[inline]
|
||||
fn last(&mut self) -> Option<A> {
|
||||
@ -865,7 +865,7 @@ pub trait OrdIterator<A> {
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// assert!(a.iter().max().get() == &5);
|
||||
/// assert!(a.iter().max().unwrap() == &5);
|
||||
/// ```
|
||||
fn max(&mut self) -> Option<A>;
|
||||
|
||||
@ -875,7 +875,7 @@ pub trait OrdIterator<A> {
|
||||
///
|
||||
/// ```rust
|
||||
/// let a = [1, 2, 3, 4, 5];
|
||||
/// assert!(a.iter().min().get() == &1);
|
||||
/// assert!(a.iter().min().unwrap() == &1);
|
||||
/// ```
|
||||
fn min(&mut self) -> Option<A>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user