mirror of
https://github.com/openharmony/third_party_rust_either.git
synced 2026-07-21 03:05:24 -04:00
Restrict iterator method forwardings to the most important methods
This commit is contained in:
+3
-111
@@ -11,7 +11,7 @@
|
||||
#[cfg(all(not(test), not(feature = "use_std")))]
|
||||
extern crate core as std;
|
||||
|
||||
use std::{fmt, iter, cmp};
|
||||
use std::fmt;
|
||||
use std::convert::{AsRef, AsMut};
|
||||
use std::ops::Deref;
|
||||
use std::ops::DerefMut;
|
||||
@@ -343,126 +343,18 @@ impl<L, R> Iterator for Either<L, R>
|
||||
fn nth(&mut self, n: usize) -> Option<Self::Item> {
|
||||
either!(*self, ref mut inner => inner.nth(n))
|
||||
}
|
||||
|
||||
|
||||
fn collect<B>(self) -> B
|
||||
where B: iter::FromIterator<Self::Item>
|
||||
{
|
||||
either!(self, inner => inner.collect())
|
||||
}
|
||||
|
||||
fn partition<B, F>(self, f: F) -> (B, B)
|
||||
where B: Default + Extend<Self::Item>, F: FnMut(&Self::Item) -> bool
|
||||
{
|
||||
either!(self, inner => inner.partition(f))
|
||||
}
|
||||
|
||||
|
||||
fn all<F>(&mut self, f: F) -> bool
|
||||
where F: FnMut(Self::Item) -> bool
|
||||
{
|
||||
either!(*self, ref mut inner => inner.all(f))
|
||||
}
|
||||
|
||||
fn any<F>(&mut self, f: F) -> bool
|
||||
where F: FnMut(Self::Item) -> bool
|
||||
{
|
||||
either!(*self, ref mut inner => inner.any(f))
|
||||
}
|
||||
|
||||
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
|
||||
where P: FnMut(&Self::Item) -> bool
|
||||
{
|
||||
either!(*self, ref mut inner => inner.find(predicate))
|
||||
}
|
||||
|
||||
fn position<P>(&mut self, predicate: P) -> Option<usize>
|
||||
where P: FnMut(Self::Item) -> bool
|
||||
{
|
||||
either!(*self, ref mut inner => inner.position(predicate))
|
||||
}
|
||||
|
||||
fn max(self) -> Option<Self::Item>
|
||||
where Self::Item: Ord
|
||||
{
|
||||
either!(self, inner => inner.max())
|
||||
}
|
||||
|
||||
fn min(self) -> Option<Self::Item>
|
||||
where Self::Item: Ord
|
||||
{
|
||||
either!(self, inner => inner.min())
|
||||
}
|
||||
|
||||
fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>
|
||||
where B: Ord, F: FnMut(&Self::Item) -> B
|
||||
{
|
||||
either!(self, inner => inner.max_by_key(f))
|
||||
}
|
||||
|
||||
fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>
|
||||
where B: Ord, F: FnMut(&Self::Item) -> B
|
||||
{
|
||||
either!(self, inner => inner.min_by_key(f))
|
||||
}
|
||||
|
||||
fn sum<S>(self) -> S
|
||||
where S: iter::Sum<Self::Item>
|
||||
{
|
||||
either!(self, inner => inner.sum())
|
||||
}
|
||||
|
||||
fn product<S>(self) -> S
|
||||
where S: iter::Product<Self::Item>
|
||||
{
|
||||
either!(self, inner => inner.product())
|
||||
}
|
||||
|
||||
fn cmp<I>(self, other: I) -> cmp::Ordering
|
||||
where I: IntoIterator<Item=Self::Item>, Self::Item: Ord
|
||||
{
|
||||
either!(self, inner => inner.cmp(other))
|
||||
}
|
||||
|
||||
fn partial_cmp<I>(self, other: I) -> Option<cmp::Ordering>
|
||||
where I: IntoIterator, Self::Item: PartialOrd<I::Item>
|
||||
{
|
||||
either!(self, inner => inner.partial_cmp(other))
|
||||
}
|
||||
|
||||
fn eq<I>(self, other: I) -> bool
|
||||
where I: IntoIterator, Self::Item: PartialEq<I::Item>
|
||||
{
|
||||
either!(self, inner => inner.eq(other))
|
||||
}
|
||||
|
||||
fn ne<I>(self, other: I) -> bool
|
||||
where I: IntoIterator, Self::Item: PartialEq<I::Item>
|
||||
{
|
||||
either!(self, inner => inner.ne(other))
|
||||
}
|
||||
|
||||
fn lt<I>(self, other: I) -> bool
|
||||
where I: IntoIterator, Self::Item: PartialOrd<I::Item>
|
||||
{
|
||||
either!(self, inner => inner.lt(other))
|
||||
}
|
||||
|
||||
fn le<I>(self, other: I) -> bool
|
||||
where I: IntoIterator, Self::Item: PartialOrd<I::Item>
|
||||
{
|
||||
either!(self, inner => inner.le(other))
|
||||
}
|
||||
|
||||
fn gt<I>(self, other: I) -> bool
|
||||
where I: IntoIterator, Self::Item: PartialOrd<I::Item>
|
||||
{
|
||||
either!(self, inner => inner.gt(other))
|
||||
}
|
||||
|
||||
fn ge<I>(self, other: I) -> bool
|
||||
where I: IntoIterator, Self::Item: PartialOrd<I::Item>
|
||||
{
|
||||
either!(self, inner => inner.ge(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl<L, R> DoubleEndedIterator for Either<L, R>
|
||||
|
||||
Reference in New Issue
Block a user