diff --git a/src/lib.rs b/src/lib.rs index 0082aa989..fcefd997e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1999,6 +1999,15 @@ pub trait Itertools: Iterator { /// assert_eq!(numbers.iter().find_or_last(|&&x| x > 5), Some(&4)); /// assert_eq!(numbers.iter().find_or_last(|&&x| x > 2), Some(&3)); /// assert_eq!(std::iter::empty::().find_or_last(|&x| x > 5), None); + /// + /// // An iterator of Results can return the first Ok or the last Err: + /// let input = vec![Err(()), Ok(11), Err(()), Ok(22)]; + /// assert_eq!(.into_iter().find_or_last(Result::is_ok), Some(Ok(11))); + /// + /// let input: Vec> = vec![Err(11), Err(22)]; + /// assert_eq!(input.into_iter().find_or_last(Result::is_ok), Some(Err(22))); + /// + /// assert_eq!(std::iter::empty::>().find_or_last(Result::is_ok), None); /// ``` fn find_or_last

(mut self, mut predicate: P) -> Option where @@ -2027,6 +2036,15 @@ pub trait Itertools: Iterator { /// assert_eq!(numbers.iter().find_or_first(|&&x| x > 5), Some(&1)); /// assert_eq!(numbers.iter().find_or_first(|&&x| x > 2), Some(&3)); /// assert_eq!(std::iter::empty::().find_or_first(|&x| x > 5), None); + /// + /// // An iterator of Results can return the first Ok or the last Err: + /// let input = vec![Err(()), Ok(11), Err(()), Ok(22)]; + /// assert_eq!(input.into_iter().find_or_first(Result::is_ok), Some(Ok(11))); + /// + /// let input: Vec> = vec![Err(11), Err(22)]; + /// assert_eq!(input.into_iter().find_or_first(Result::is_ok), Some(Err(11))); + /// + /// assert_eq!(std::iter::empty::>().find_or_first(Result::is_ok), None); /// ``` fn find_or_first

(mut self, mut predicate: P) -> Option where