|
1 | 1 | #![warn(missing_docs)]
|
2 | 2 | #![crate_name="itertools"]
|
3 | 3 | #![cfg_attr(not(feature = "use_std"), no_std)]
|
4 |
| -#![feature(control_flow_enum)] |
5 | 4 |
|
6 | 5 | //! Extra iterator adaptors, functions and macros.
|
7 | 6 | //!
|
@@ -76,7 +75,6 @@ use std::fmt::Write;
|
76 | 75 | type VecIntoIter<T> = alloc::vec::IntoIter<T>;
|
77 | 76 | #[cfg(feature = "use_alloc")]
|
78 | 77 | use std::iter::FromIterator;
|
79 |
| -use std::ops::ControlFlow; |
80 | 78 |
|
81 | 79 | #[macro_use]
|
82 | 80 | mod impl_macros;
|
@@ -1747,16 +1745,13 @@ pub trait Itertools : Iterator {
|
1747 | 1745 | P: FnMut(&Self::Item) -> bool,
|
1748 | 1746 | {
|
1749 | 1747 | #[inline]
|
1750 |
| - fn check<T>(mut predicate: impl FnMut(&T) -> bool) -> impl FnMut(Option<T>, T) -> ControlFlow<T, Option<T>> { |
| 1748 | + fn check<T>(mut predicate: impl FnMut(&T) -> bool) -> impl FnMut(Option<T>, T) -> Result<Option<T>, T> { |
1751 | 1749 | move |_, x| {
|
1752 |
| - if predicate(&x) { ControlFlow::Break(x) } else { ControlFlow::Continue(Some(x)) } |
| 1750 | + if predicate(&x) { Result::Err(x) } else { Result::Ok(Some(x)) } |
1753 | 1751 | }
|
1754 | 1752 | }
|
1755 | 1753 |
|
1756 |
| - match self.try_fold(None, check(predicate)) { |
1757 |
| - ControlFlow::Continue(x) => x, |
1758 |
| - ControlFlow::Break(x) => Some(x), |
1759 |
| - } |
| 1754 | + self.try_fold(None, check(predicate)).unwrap_or_else(Some) |
1760 | 1755 | }
|
1761 | 1756 | /// Returns `true` if the given item is present in this iterator.
|
1762 | 1757 | ///
|
|
0 commit comments