|
|
@ -69,6 +69,7 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {}
|
|
|
|
#[doc(notable_trait)]
|
|
|
|
#[doc(notable_trait)]
|
|
|
|
#[rustc_diagnostic_item = "Iterator"]
|
|
|
|
#[rustc_diagnostic_item = "Iterator"]
|
|
|
|
#[must_use = "iterators are lazy and do nothing unless consumed"]
|
|
|
|
#[must_use = "iterators are lazy and do nothing unless consumed"]
|
|
|
|
|
|
|
|
#[cfg_attr(not(bootstrap), const_trait)]
|
|
|
|
pub trait Iterator {
|
|
|
|
pub trait Iterator {
|
|
|
|
/// The type of the elements being iterated over.
|
|
|
|
/// The type of the elements being iterated over.
|
|
|
|
#[rustc_diagnostic_item = "IteratorItem"]
|
|
|
|
#[rustc_diagnostic_item = "IteratorItem"]
|
|
|
@ -141,6 +142,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[unstable(feature = "iter_next_chunk", reason = "recently added", issue = "98326")]
|
|
|
|
#[unstable(feature = "iter_next_chunk", reason = "recently added", issue = "98326")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn next_chunk<const N: usize>(
|
|
|
|
fn next_chunk<const N: usize>(
|
|
|
|
&mut self,
|
|
|
|
&mut self,
|
|
|
|
) -> Result<[Self::Item; N], array::IntoIter<Self::Item, N>>
|
|
|
|
) -> Result<[Self::Item; N], array::IntoIter<Self::Item, N>>
|
|
|
@ -218,6 +220,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
|
|
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
|
|
|
(0, None)
|
|
|
|
(0, None)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -255,6 +258,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn count(self) -> usize
|
|
|
|
fn count(self) -> usize
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -285,6 +289,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn last(self) -> Option<Self::Item>
|
|
|
|
fn last(self) -> Option<Self::Item>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -331,6 +336,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[unstable(feature = "iter_advance_by", reason = "recently added", issue = "77404")]
|
|
|
|
#[unstable(feature = "iter_advance_by", reason = "recently added", issue = "77404")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn advance_by(&mut self, n: usize) -> Result<(), usize> {
|
|
|
|
fn advance_by(&mut self, n: usize) -> Result<(), usize> {
|
|
|
|
for i in 0..n {
|
|
|
|
for i in 0..n {
|
|
|
|
self.next().ok_or(i)?;
|
|
|
|
self.next().ok_or(i)?;
|
|
|
@ -379,6 +385,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn nth(&mut self, n: usize) -> Option<Self::Item> {
|
|
|
|
fn nth(&mut self, n: usize) -> Option<Self::Item> {
|
|
|
|
self.advance_by(n).ok()?;
|
|
|
|
self.advance_by(n).ok()?;
|
|
|
|
self.next()
|
|
|
|
self.next()
|
|
|
@ -431,6 +438,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "iterator_step_by", since = "1.28.0")]
|
|
|
|
#[stable(feature = "iterator_step_by", since = "1.28.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn step_by(self, step: usize) -> StepBy<Self>
|
|
|
|
fn step_by(self, step: usize) -> StepBy<Self>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -502,6 +510,7 @@ pub trait Iterator {
|
|
|
|
/// [`OsStr`]: ../../std/ffi/struct.OsStr.html
|
|
|
|
/// [`OsStr`]: ../../std/ffi/struct.OsStr.html
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn chain<U>(self, other: U) -> Chain<Self, U::IntoIter>
|
|
|
|
fn chain<U>(self, other: U) -> Chain<Self, U::IntoIter>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -620,6 +629,7 @@ pub trait Iterator {
|
|
|
|
/// [`zip`]: crate::iter::zip
|
|
|
|
/// [`zip`]: crate::iter::zip
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn zip<U>(self, other: U) -> Zip<Self, U::IntoIter>
|
|
|
|
fn zip<U>(self, other: U) -> Zip<Self, U::IntoIter>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -662,6 +672,7 @@ pub trait Iterator {
|
|
|
|
/// [`intersperse_with`]: Iterator::intersperse_with
|
|
|
|
/// [`intersperse_with`]: Iterator::intersperse_with
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
|
|
|
|
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
|
|
|
|
fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -720,6 +731,7 @@ pub trait Iterator {
|
|
|
|
/// [`intersperse`]: Iterator::intersperse
|
|
|
|
/// [`intersperse`]: Iterator::intersperse
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
|
|
|
|
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
|
|
|
|
fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -779,6 +791,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn map<B, F>(self, f: F) -> Map<Self, F>
|
|
|
|
fn map<B, F>(self, f: F) -> Map<Self, F>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -824,6 +837,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "iterator_for_each", since = "1.21.0")]
|
|
|
|
#[stable(feature = "iterator_for_each", since = "1.21.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn for_each<F>(self, f: F)
|
|
|
|
fn for_each<F>(self, f: F)
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -899,6 +913,7 @@ pub trait Iterator {
|
|
|
|
/// Note that `iter.filter(f).next()` is equivalent to `iter.find(f)`.
|
|
|
|
/// Note that `iter.filter(f).next()` is equivalent to `iter.find(f)`.
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn filter<P>(self, predicate: P) -> Filter<Self, P>
|
|
|
|
fn filter<P>(self, predicate: P) -> Filter<Self, P>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -944,6 +959,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
|
|
|
|
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -990,6 +1006,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn enumerate(self) -> Enumerate<Self>
|
|
|
|
fn enumerate(self) -> Enumerate<Self>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -1061,6 +1078,7 @@ pub trait Iterator {
|
|
|
|
/// [`next`]: Iterator::next
|
|
|
|
/// [`next`]: Iterator::next
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn peekable(self) -> Peekable<Self>
|
|
|
|
fn peekable(self) -> Peekable<Self>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -1126,6 +1144,7 @@ pub trait Iterator {
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[doc(alias = "drop_while")]
|
|
|
|
#[doc(alias = "drop_while")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
|
|
|
|
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -1207,6 +1226,7 @@ pub trait Iterator {
|
|
|
|
/// the iteration should stop, but wasn't placed back into the iterator.
|
|
|
|
/// the iteration should stop, but wasn't placed back into the iterator.
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
|
|
|
|
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -1295,6 +1315,7 @@ pub trait Iterator {
|
|
|
|
/// [`fuse`]: Iterator::fuse
|
|
|
|
/// [`fuse`]: Iterator::fuse
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "iter_map_while", since = "1.57.0")]
|
|
|
|
#[stable(feature = "iter_map_while", since = "1.57.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
|
|
|
|
fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -1326,6 +1347,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn skip(self, n: usize) -> Skip<Self>
|
|
|
|
fn skip(self, n: usize) -> Skip<Self>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -1379,6 +1401,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn take(self, n: usize) -> Take<Self>
|
|
|
|
fn take(self, n: usize) -> Take<Self>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -1428,6 +1451,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
|
|
|
|
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -1468,6 +1492,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
|
|
|
|
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -1552,6 +1577,7 @@ pub trait Iterator {
|
|
|
|
/// [`flat_map()`]: Iterator::flat_map
|
|
|
|
/// [`flat_map()`]: Iterator::flat_map
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "iterator_flatten", since = "1.29.0")]
|
|
|
|
#[stable(feature = "iterator_flatten", since = "1.29.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn flatten(self) -> Flatten<Self>
|
|
|
|
fn flatten(self) -> Flatten<Self>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -1620,6 +1646,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn fuse(self) -> Fuse<Self>
|
|
|
|
fn fuse(self) -> Fuse<Self>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -1704,6 +1731,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn inspect<F>(self, f: F) -> Inspect<Self, F>
|
|
|
|
fn inspect<F>(self, f: F) -> Inspect<Self, F>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -1734,6 +1762,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!(of_rust, vec!["of", "Rust"]);
|
|
|
|
/// assert_eq!(of_rust, vec!["of", "Rust"]);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn by_ref(&mut self) -> &mut Self
|
|
|
|
fn by_ref(&mut self) -> &mut Self
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -1853,6 +1882,7 @@ pub trait Iterator {
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]
|
|
|
|
#[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]
|
|
|
|
#[cfg_attr(not(test), rustc_diagnostic_item = "iterator_collect_fn")]
|
|
|
|
#[cfg_attr(not(test), rustc_diagnostic_item = "iterator_collect_fn")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn collect<B: FromIterator<Self::Item>>(self) -> B
|
|
|
|
fn collect<B: FromIterator<Self::Item>>(self) -> B
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -1931,6 +1961,7 @@ pub trait Iterator {
|
|
|
|
/// [`collect`]: Iterator::collect
|
|
|
|
/// [`collect`]: Iterator::collect
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[unstable(feature = "iterator_try_collect", issue = "94047")]
|
|
|
|
#[unstable(feature = "iterator_try_collect", issue = "94047")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn try_collect<B>(&mut self) -> ChangeOutputType<Self::Item, B>
|
|
|
|
fn try_collect<B>(&mut self) -> ChangeOutputType<Self::Item, B>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2004,6 +2035,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[unstable(feature = "iter_collect_into", reason = "new API", issue = "94780")]
|
|
|
|
#[unstable(feature = "iter_collect_into", reason = "new API", issue = "94780")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn collect_into<E: Extend<Self::Item>>(self, collection: &mut E) -> &mut E
|
|
|
|
fn collect_into<E: Extend<Self::Item>>(self, collection: &mut E) -> &mut E
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2038,6 +2070,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!(odd, vec![1, 3]);
|
|
|
|
/// assert_eq!(odd, vec![1, 3]);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn partition<B, F>(self, f: F) -> (B, B)
|
|
|
|
fn partition<B, F>(self, f: F) -> (B, B)
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2100,6 +2133,7 @@ pub trait Iterator {
|
|
|
|
/// assert!(a[i..].iter().all(|&n| n % 2 == 1)); // odds
|
|
|
|
/// assert!(a[i..].iter().all(|&n| n % 2 == 1)); // odds
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[unstable(feature = "iter_partition_in_place", reason = "new API", issue = "62543")]
|
|
|
|
#[unstable(feature = "iter_partition_in_place", reason = "new API", issue = "62543")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn partition_in_place<'a, T: 'a, P>(mut self, ref mut predicate: P) -> usize
|
|
|
|
fn partition_in_place<'a, T: 'a, P>(mut self, ref mut predicate: P) -> usize
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized + DoubleEndedIterator<Item = &'a mut T>,
|
|
|
|
Self: Sized + DoubleEndedIterator<Item = &'a mut T>,
|
|
|
@ -2157,6 +2191,7 @@ pub trait Iterator {
|
|
|
|
/// assert!(!"IntoIterator".chars().is_partitioned(char::is_uppercase));
|
|
|
|
/// assert!(!"IntoIterator".chars().is_partitioned(char::is_uppercase));
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[unstable(feature = "iter_is_partitioned", reason = "new API", issue = "62544")]
|
|
|
|
#[unstable(feature = "iter_is_partitioned", reason = "new API", issue = "62544")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn is_partitioned<P>(mut self, mut predicate: P) -> bool
|
|
|
|
fn is_partitioned<P>(mut self, mut predicate: P) -> bool
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2251,6 +2286,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "iterator_try_fold", since = "1.27.0")]
|
|
|
|
#[stable(feature = "iterator_try_fold", since = "1.27.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn try_fold<B, F, R>(&mut self, init: B, mut f: F) -> R
|
|
|
|
fn try_fold<B, F, R>(&mut self, init: B, mut f: F) -> R
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2309,6 +2345,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "iterator_try_fold", since = "1.27.0")]
|
|
|
|
#[stable(feature = "iterator_try_fold", since = "1.27.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn try_for_each<F, R>(&mut self, f: F) -> R
|
|
|
|
fn try_for_each<F, R>(&mut self, f: F) -> R
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2428,6 +2465,7 @@ pub trait Iterator {
|
|
|
|
#[doc(alias = "inject", alias = "foldl")]
|
|
|
|
#[doc(alias = "inject", alias = "foldl")]
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn fold<B, F>(mut self, init: B, mut f: F) -> B
|
|
|
|
fn fold<B, F>(mut self, init: B, mut f: F) -> B
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2465,6 +2503,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "iterator_fold_self", since = "1.51.0")]
|
|
|
|
#[stable(feature = "iterator_fold_self", since = "1.51.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn reduce<F>(mut self, f: F) -> Option<Self::Item>
|
|
|
|
fn reduce<F>(mut self, f: F) -> Option<Self::Item>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2536,6 +2575,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[unstable(feature = "iterator_try_reduce", reason = "new API", issue = "87053")]
|
|
|
|
#[unstable(feature = "iterator_try_reduce", reason = "new API", issue = "87053")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn try_reduce<F, R>(&mut self, f: F) -> ChangeOutputType<R, Option<R::Output>>
|
|
|
|
fn try_reduce<F, R>(&mut self, f: F) -> ChangeOutputType<R, Option<R::Output>>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2593,6 +2633,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn all<F>(&mut self, f: F) -> bool
|
|
|
|
fn all<F>(&mut self, f: F) -> bool
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2646,6 +2687,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn any<F>(&mut self, f: F) -> bool
|
|
|
|
fn any<F>(&mut self, f: F) -> bool
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2709,6 +2751,7 @@ pub trait Iterator {
|
|
|
|
/// Note that `iter.find(f)` is equivalent to `iter.filter(f).next()`.
|
|
|
|
/// Note that `iter.find(f)` is equivalent to `iter.filter(f).next()`.
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
|
|
|
|
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2740,6 +2783,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "iterator_find_map", since = "1.30.0")]
|
|
|
|
#[stable(feature = "iterator_find_map", since = "1.30.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn find_map<B, F>(&mut self, f: F) -> Option<B>
|
|
|
|
fn find_map<B, F>(&mut self, f: F) -> Option<B>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2796,6 +2840,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[unstable(feature = "try_find", reason = "new API", issue = "63178")]
|
|
|
|
#[unstable(feature = "try_find", reason = "new API", issue = "63178")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn try_find<F, R>(&mut self, f: F) -> ChangeOutputType<R, Option<Self::Item>>
|
|
|
|
fn try_find<F, R>(&mut self, f: F) -> ChangeOutputType<R, Option<Self::Item>>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2878,6 +2923,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn position<P>(&mut self, predicate: P) -> Option<usize>
|
|
|
|
fn position<P>(&mut self, predicate: P) -> Option<usize>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -2935,6 +2981,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn rposition<P>(&mut self, predicate: P) -> Option<usize>
|
|
|
|
fn rposition<P>(&mut self, predicate: P) -> Option<usize>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
P: FnMut(Self::Item) -> bool,
|
|
|
|
P: FnMut(Self::Item) -> bool,
|
|
|
@ -2986,6 +3033,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn max(self) -> Option<Self::Item>
|
|
|
|
fn max(self) -> Option<Self::Item>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3024,6 +3072,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn min(self) -> Option<Self::Item>
|
|
|
|
fn min(self) -> Option<Self::Item>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3046,6 +3095,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "iter_cmp_by_key", since = "1.6.0")]
|
|
|
|
#[stable(feature = "iter_cmp_by_key", since = "1.6.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn max_by_key<B: Ord, F>(self, f: F) -> Option<Self::Item>
|
|
|
|
fn max_by_key<B: Ord, F>(self, f: F) -> Option<Self::Item>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3079,6 +3129,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "iter_max_by", since = "1.15.0")]
|
|
|
|
#[stable(feature = "iter_max_by", since = "1.15.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn max_by<F>(self, compare: F) -> Option<Self::Item>
|
|
|
|
fn max_by<F>(self, compare: F) -> Option<Self::Item>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3106,6 +3157,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "iter_cmp_by_key", since = "1.6.0")]
|
|
|
|
#[stable(feature = "iter_cmp_by_key", since = "1.6.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn min_by_key<B: Ord, F>(self, f: F) -> Option<Self::Item>
|
|
|
|
fn min_by_key<B: Ord, F>(self, f: F) -> Option<Self::Item>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3139,6 +3191,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[stable(feature = "iter_min_by", since = "1.15.0")]
|
|
|
|
#[stable(feature = "iter_min_by", since = "1.15.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn min_by<F>(self, compare: F) -> Option<Self::Item>
|
|
|
|
fn min_by<F>(self, compare: F) -> Option<Self::Item>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3176,6 +3229,7 @@ pub trait Iterator {
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[doc(alias = "reverse")]
|
|
|
|
#[doc(alias = "reverse")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn rev(self) -> Rev<Self>
|
|
|
|
fn rev(self) -> Rev<Self>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized + DoubleEndedIterator,
|
|
|
|
Self: Sized + DoubleEndedIterator,
|
|
|
@ -3214,6 +3268,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!(z, [3, 6]);
|
|
|
|
/// assert_eq!(z, [3, 6]);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
|
|
|
|
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
|
|
|
|
where
|
|
|
|
where
|
|
|
|
FromA: Default + Extend<A>,
|
|
|
|
FromA: Default + Extend<A>,
|
|
|
@ -3246,6 +3301,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!(v_map, vec![1, 2, 3]);
|
|
|
|
/// assert_eq!(v_map, vec![1, 2, 3]);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "iter_copied", since = "1.36.0")]
|
|
|
|
#[stable(feature = "iter_copied", since = "1.36.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn copied<'a, T: 'a>(self) -> Copied<Self>
|
|
|
|
fn copied<'a, T: 'a>(self) -> Copied<Self>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized + Iterator<Item = &'a T>,
|
|
|
|
Self: Sized + Iterator<Item = &'a T>,
|
|
|
@ -3293,6 +3349,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!(&[vec![23]], &faster[..]);
|
|
|
|
/// assert_eq!(&[vec![23]], &faster[..]);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn cloned<'a, T: 'a>(self) -> Cloned<Self>
|
|
|
|
fn cloned<'a, T: 'a>(self) -> Cloned<Self>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized + Iterator<Item = &'a T>,
|
|
|
|
Self: Sized + Iterator<Item = &'a T>,
|
|
|
@ -3327,6 +3384,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn cycle(self) -> Cycle<Self>
|
|
|
|
fn cycle(self) -> Cycle<Self>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized + Clone,
|
|
|
|
Self: Sized + Clone,
|
|
|
@ -3370,6 +3428,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[track_caller]
|
|
|
|
#[track_caller]
|
|
|
|
#[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")]
|
|
|
|
#[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>
|
|
|
|
fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3400,6 +3459,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!(sum, 6);
|
|
|
|
/// assert_eq!(sum, 6);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "iter_arith", since = "1.11.0")]
|
|
|
|
#[stable(feature = "iter_arith", since = "1.11.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn sum<S>(self) -> S
|
|
|
|
fn sum<S>(self) -> S
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3429,6 +3489,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!(factorial(5), 120);
|
|
|
|
/// assert_eq!(factorial(5), 120);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "iter_arith", since = "1.11.0")]
|
|
|
|
#[stable(feature = "iter_arith", since = "1.11.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn product<P>(self) -> P
|
|
|
|
fn product<P>(self) -> P
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3450,6 +3511,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!([1, 2].iter().cmp([1].iter()), Ordering::Greater);
|
|
|
|
/// assert_eq!([1, 2].iter().cmp([1].iter()), Ordering::Greater);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn cmp<I>(self, other: I) -> Ordering
|
|
|
|
fn cmp<I>(self, other: I) -> Ordering
|
|
|
|
where
|
|
|
|
where
|
|
|
|
I: IntoIterator<Item = Self::Item>,
|
|
|
|
I: IntoIterator<Item = Self::Item>,
|
|
|
@ -3479,6 +3541,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!(xs.iter().cmp_by(&ys, |&x, &y| (2 * x).cmp(&y)), Ordering::Greater);
|
|
|
|
/// assert_eq!(xs.iter().cmp_by(&ys, |&x, &y| (2 * x).cmp(&y)), Ordering::Greater);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[unstable(feature = "iter_order_by", issue = "64295")]
|
|
|
|
#[unstable(feature = "iter_order_by", issue = "64295")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
|
|
|
|
fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3535,6 +3598,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
///
|
|
|
|
///
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn partial_cmp<I>(self, other: I) -> Option<Ordering>
|
|
|
|
fn partial_cmp<I>(self, other: I) -> Option<Ordering>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I: IntoIterator,
|
|
|
@ -3573,6 +3637,7 @@ pub trait Iterator {
|
|
|
|
/// );
|
|
|
|
/// );
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[unstable(feature = "iter_order_by", issue = "64295")]
|
|
|
|
#[unstable(feature = "iter_order_by", issue = "64295")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>
|
|
|
|
fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3606,6 +3671,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!([1].iter().eq([1, 2].iter()), false);
|
|
|
|
/// assert_eq!([1].iter().eq([1, 2].iter()), false);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn eq<I>(self, other: I) -> bool
|
|
|
|
fn eq<I>(self, other: I) -> bool
|
|
|
|
where
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I: IntoIterator,
|
|
|
@ -3631,6 +3697,7 @@ pub trait Iterator {
|
|
|
|
/// assert!(xs.iter().eq_by(&ys, |&x, &y| x * x == y));
|
|
|
|
/// assert!(xs.iter().eq_by(&ys, |&x, &y| x * x == y));
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[unstable(feature = "iter_order_by", issue = "64295")]
|
|
|
|
#[unstable(feature = "iter_order_by", issue = "64295")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn eq_by<I, F>(self, other: I, eq: F) -> bool
|
|
|
|
fn eq_by<I, F>(self, other: I, eq: F) -> bool
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3663,6 +3730,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!([1].iter().ne([1, 2].iter()), true);
|
|
|
|
/// assert_eq!([1].iter().ne([1, 2].iter()), true);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn ne<I>(self, other: I) -> bool
|
|
|
|
fn ne<I>(self, other: I) -> bool
|
|
|
|
where
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I: IntoIterator,
|
|
|
@ -3684,6 +3752,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!([1, 2].iter().lt([1, 2].iter()), false);
|
|
|
|
/// assert_eq!([1, 2].iter().lt([1, 2].iter()), false);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn lt<I>(self, other: I) -> bool
|
|
|
|
fn lt<I>(self, other: I) -> bool
|
|
|
|
where
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I: IntoIterator,
|
|
|
@ -3705,6 +3774,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!([1, 2].iter().le([1, 2].iter()), true);
|
|
|
|
/// assert_eq!([1, 2].iter().le([1, 2].iter()), true);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn le<I>(self, other: I) -> bool
|
|
|
|
fn le<I>(self, other: I) -> bool
|
|
|
|
where
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I: IntoIterator,
|
|
|
@ -3726,6 +3796,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!([1, 2].iter().gt([1, 2].iter()), false);
|
|
|
|
/// assert_eq!([1, 2].iter().gt([1, 2].iter()), false);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn gt<I>(self, other: I) -> bool
|
|
|
|
fn gt<I>(self, other: I) -> bool
|
|
|
|
where
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I: IntoIterator,
|
|
|
@ -3747,6 +3818,7 @@ pub trait Iterator {
|
|
|
|
/// assert_eq!([1, 2].iter().ge([1, 2].iter()), true);
|
|
|
|
/// assert_eq!([1, 2].iter().ge([1, 2].iter()), true);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
#[stable(feature = "iter_order", since = "1.5.0")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn ge<I>(self, other: I) -> bool
|
|
|
|
fn ge<I>(self, other: I) -> bool
|
|
|
|
where
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I: IntoIterator,
|
|
|
@ -3778,6 +3850,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
|
|
|
|
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn is_sorted(self) -> bool
|
|
|
|
fn is_sorted(self) -> bool
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3806,6 +3879,7 @@ pub trait Iterator {
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// [`is_sorted`]: Iterator::is_sorted
|
|
|
|
/// [`is_sorted`]: Iterator::is_sorted
|
|
|
|
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
|
|
|
|
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn is_sorted_by<F>(mut self, compare: F) -> bool
|
|
|
|
fn is_sorted_by<F>(mut self, compare: F) -> bool
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3852,6 +3926,7 @@ pub trait Iterator {
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
|
|
|
|
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
fn is_sorted_by_key<F, K>(self, f: F) -> bool
|
|
|
|
fn is_sorted_by_key<F, K>(self, f: F) -> bool
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
Self: Sized,
|
|
|
@ -3867,6 +3942,7 @@ pub trait Iterator {
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
#[doc(hidden)]
|
|
|
|
#[doc(hidden)]
|
|
|
|
#[unstable(feature = "trusted_random_access", issue = "none")]
|
|
|
|
#[unstable(feature = "trusted_random_access", issue = "none")]
|
|
|
|
|
|
|
|
#[rustc_do_not_const_check]
|
|
|
|
unsafe fn __iterator_get_unchecked(&mut self, _idx: usize) -> Self::Item
|
|
|
|
unsafe fn __iterator_get_unchecked(&mut self, _idx: usize) -> Self::Item
|
|
|
|
where
|
|
|
|
where
|
|
|
|
Self: TrustedRandomAccessNoCoerce,
|
|
|
|
Self: TrustedRandomAccessNoCoerce,
|
|
|
|