pub enum Either<L, R> {
Left(L),
Right(R),
}
Expand description
The enum Either
with variants Left
and Right
is a general purpose
sum type with two cases.
The Either
type is symmetric and treats its variants the same way, without
preference.
(For representing success or error, use the regular Result
enum instead.)
Variants§
Implementations§
Source§impl<L, R> Either<L, R>
impl<L, R> Either<L, R>
Sourcepub fn is_left(&self) -> bool
pub fn is_left(&self) -> bool
Return true if the value is the Left
variant.
use either::*;
let values = [Left(1), Right("the right value")];
assert_eq!(values[0].is_left(), true);
assert_eq!(values[1].is_left(), false);
Sourcepub fn is_right(&self) -> bool
pub fn is_right(&self) -> bool
Return true if the value is the Right
variant.
use either::*;
let values = [Left(1), Right("the right value")];
assert_eq!(values[0].is_right(), false);
assert_eq!(values[1].is_right(), true);
Sourcepub fn left(self) -> Option<L>
pub fn left(self) -> Option<L>
Convert the left side of Either<L, R>
to an Option<L>
.
use either::*;
let left: Either<_, ()> = Left("some value");
assert_eq!(left.left(), Some("some value"));
let right: Either<(), _> = Right(321);
assert_eq!(right.left(), None);
Sourcepub fn right(self) -> Option<R>
pub fn right(self) -> Option<R>
Convert the right side of Either<L, R>
to an Option<R>
.
use either::*;
let left: Either<_, ()> = Left("some value");
assert_eq!(left.right(), None);
let right: Either<(), _> = Right(321);
assert_eq!(right.right(), Some(321));
Sourcepub fn as_ref(&self) -> Either<&L, &R> ⓘ
pub fn as_ref(&self) -> Either<&L, &R> ⓘ
Convert &Either<L, R>
to Either<&L, &R>
.
use either::*;
let left: Either<_, ()> = Left("some value");
assert_eq!(left.as_ref(), Left(&"some value"));
let right: Either<(), _> = Right("some value");
assert_eq!(right.as_ref(), Right(&"some value"));
Sourcepub fn as_mut(&mut self) -> Either<&mut L, &mut R> ⓘ
pub fn as_mut(&mut self) -> Either<&mut L, &mut R> ⓘ
Convert &mut Either<L, R>
to Either<&mut L, &mut R>
.
use either::*;
fn mutate_left(value: &mut Either<u32, u32>) {
if let Some(l) = value.as_mut().left() {
*l = 999;
}
}
let mut left = Left(123);
let mut right = Right(123);
mutate_left(&mut left);
mutate_left(&mut right);
assert_eq!(left, Left(999));
assert_eq!(right, Right(123));
Sourcepub fn as_pin_ref(self: Pin<&Either<L, R>>) -> Either<Pin<&L>, Pin<&R>> ⓘ
pub fn as_pin_ref(self: Pin<&Either<L, R>>) -> Either<Pin<&L>, Pin<&R>> ⓘ
Convert Pin<&Either<L, R>>
to Either<Pin<&L>, Pin<&R>>
,
pinned projections of the inner variants.
Sourcepub fn as_pin_mut(
self: Pin<&mut Either<L, R>>,
) -> Either<Pin<&mut L>, Pin<&mut R>> ⓘ
pub fn as_pin_mut( self: Pin<&mut Either<L, R>>, ) -> Either<Pin<&mut L>, Pin<&mut R>> ⓘ
Convert Pin<&mut Either<L, R>>
to Either<Pin<&mut L>, Pin<&mut R>>
,
pinned projections of the inner variants.
Sourcepub fn flip(self) -> Either<R, L> ⓘ
pub fn flip(self) -> Either<R, L> ⓘ
Convert Either<L, R>
to Either<R, L>
.
use either::*;
let left: Either<_, ()> = Left(123);
assert_eq!(left.flip(), Right(123));
let right: Either<(), _> = Right("some value");
assert_eq!(right.flip(), Left("some value"));
Sourcepub fn map_left<F, M>(self, f: F) -> Either<M, R> ⓘwhere
F: FnOnce(L) -> M,
pub fn map_left<F, M>(self, f: F) -> Either<M, R> ⓘwhere
F: FnOnce(L) -> M,
Apply the function f
on the value in the Left
variant if it is present rewrapping the
result in Left
.
use either::*;
let left: Either<_, u32> = Left(123);
assert_eq!(left.map_left(|x| x * 2), Left(246));
let right: Either<u32, _> = Right(123);
assert_eq!(right.map_left(|x| x * 2), Right(123));
Sourcepub fn map_right<F, S>(self, f: F) -> Either<L, S> ⓘwhere
F: FnOnce(R) -> S,
pub fn map_right<F, S>(self, f: F) -> Either<L, S> ⓘwhere
F: FnOnce(R) -> S,
Apply the function f
on the value in the Right
variant if it is present rewrapping the
result in Right
.
use either::*;
let left: Either<_, u32> = Left(123);
assert_eq!(left.map_right(|x| x * 2), Left(123));
let right: Either<u32, _> = Right(123);
assert_eq!(right.map_right(|x| x * 2), Right(246));
Sourcepub fn map_either<F, G, M, S>(self, f: F, g: G) -> Either<M, S> ⓘ
pub fn map_either<F, G, M, S>(self, f: F, g: G) -> Either<M, S> ⓘ
Apply the functions f
and g
to the Left
and Right
variants
respectively. This is equivalent to
bimap
in functional programming.
use either::*;
let f = |s: String| s.len();
let g = |u: u8| u.to_string();
let left: Either<String, u8> = Left("loopy".into());
assert_eq!(left.map_either(f, g), Left(5));
let right: Either<String, u8> = Right(42);
assert_eq!(right.map_either(f, g), Right("42".into()));
Sourcepub fn map_either_with<Ctx, F, G, M, S>(
self,
ctx: Ctx,
f: F,
g: G,
) -> Either<M, S> ⓘ
pub fn map_either_with<Ctx, F, G, M, S>( self, ctx: Ctx, f: F, g: G, ) -> Either<M, S> ⓘ
Similar to map_either
, with an added context ctx
accessible to
both functions.
use either::*;
let mut sum = 0;
// Both closures want to update the same value, so pass it as context.
let mut f = |sum: &mut usize, s: String| { *sum += s.len(); s.to_uppercase() };
let mut g = |sum: &mut usize, u: usize| { *sum += u; u.to_string() };
let left: Either<String, usize> = Left("loopy".into());
assert_eq!(left.map_either_with(&mut sum, &mut f, &mut g), Left("LOOPY".into()));
let right: Either<String, usize> = Right(42);
assert_eq!(right.map_either_with(&mut sum, &mut f, &mut g), Right("42".into()));
assert_eq!(sum, 47);
Sourcepub fn either<F, G, T>(self, f: F, g: G) -> T
pub fn either<F, G, T>(self, f: F, g: G) -> T
Apply one of two functions depending on contents, unifying their result. If the value is
Left(L)
then the first function f
is applied; if it is Right(R)
then the second
function g
is applied.
use either::*;
fn square(n: u32) -> i32 { (n * n) as i32 }
fn negate(n: i32) -> i32 { -n }
let left: Either<u32, i32> = Left(4);
assert_eq!(left.either(square, negate), 16);
let right: Either<u32, i32> = Right(-4);
assert_eq!(right.either(square, negate), 4);
Sourcepub fn either_with<Ctx, F, G, T>(self, ctx: Ctx, f: F, g: G) -> T
pub fn either_with<Ctx, F, G, T>(self, ctx: Ctx, f: F, g: G) -> T
Like either
, but provide some context to whichever of the
functions ends up being called.
// In this example, the context is a mutable reference
use either::*;
let mut result = Vec::new();
let values = vec![Left(2), Right(2.7)];
for value in values {
value.either_with(&mut result,
|ctx, integer| ctx.push(integer),
|ctx, real| ctx.push(f64::round(real) as i32));
}
assert_eq!(result, vec![2, 3]);
Sourcepub fn left_and_then<F, S>(self, f: F) -> Either<S, R> ⓘ
pub fn left_and_then<F, S>(self, f: F) -> Either<S, R> ⓘ
Apply the function f
on the value in the Left
variant if it is present.
use either::*;
let left: Either<_, u32> = Left(123);
assert_eq!(left.left_and_then::<_,()>(|x| Right(x * 2)), Right(246));
let right: Either<u32, _> = Right(123);
assert_eq!(right.left_and_then(|x| Right::<(), _>(x * 2)), Right(123));
Sourcepub fn right_and_then<F, S>(self, f: F) -> Either<L, S> ⓘ
pub fn right_and_then<F, S>(self, f: F) -> Either<L, S> ⓘ
Apply the function f
on the value in the Right
variant if it is present.
use either::*;
let left: Either<_, u32> = Left(123);
assert_eq!(left.right_and_then(|x| Right(x * 2)), Left(123));
let right: Either<u32, _> = Right(123);
assert_eq!(right.right_and_then(|x| Right(x * 2)), Right(246));
Sourcepub fn into_iter(
self,
) -> Either<<L as IntoIterator>::IntoIter, <R as IntoIterator>::IntoIter> ⓘ
pub fn into_iter( self, ) -> Either<<L as IntoIterator>::IntoIter, <R as IntoIterator>::IntoIter> ⓘ
Convert the inner value to an iterator.
This requires the Left
and Right
iterators to have the same item type.
See factor_into_iter
to iterate different types.
use either::*;
let left: Either<_, Vec<u32>> = Left(vec![1, 2, 3, 4, 5]);
let mut right: Either<Vec<u32>, _> = Right(vec![]);
right.extend(left.into_iter());
assert_eq!(right, Right(vec![1, 2, 3, 4, 5]));
Sourcepub fn iter(
&self,
) -> Either<<&L as IntoIterator>::IntoIter, <&R as IntoIterator>::IntoIter> ⓘwhere
&'a L: for<'a> IntoIterator,
&'a R: for<'a> IntoIterator<Item = <&'a L as IntoIterator>::Item>,
pub fn iter(
&self,
) -> Either<<&L as IntoIterator>::IntoIter, <&R as IntoIterator>::IntoIter> ⓘwhere
&'a L: for<'a> IntoIterator,
&'a R: for<'a> IntoIterator<Item = <&'a L as IntoIterator>::Item>,
Borrow the inner value as an iterator.
This requires the Left
and Right
iterators to have the same item type.
See factor_iter
to iterate different types.
use either::*;
let left: Either<_, &[u32]> = Left(vec![2, 3]);
let mut right: Either<Vec<u32>, _> = Right(&[4, 5][..]);
let mut all = vec![1];
all.extend(left.iter());
all.extend(right.iter());
assert_eq!(all, vec![1, 2, 3, 4, 5]);
Sourcepub fn iter_mut(
&mut self,
) -> Either<<&mut L as IntoIterator>::IntoIter, <&mut R as IntoIterator>::IntoIter> ⓘwhere
&'a mut L: for<'a> IntoIterator,
&'a mut R: for<'a> IntoIterator<Item = <&'a mut L as IntoIterator>::Item>,
pub fn iter_mut(
&mut self,
) -> Either<<&mut L as IntoIterator>::IntoIter, <&mut R as IntoIterator>::IntoIter> ⓘwhere
&'a mut L: for<'a> IntoIterator,
&'a mut R: for<'a> IntoIterator<Item = <&'a mut L as IntoIterator>::Item>,
Mutably borrow the inner value as an iterator.
This requires the Left
and Right
iterators to have the same item type.
See factor_iter_mut
to iterate different types.
use either::*;
let mut left: Either<_, &mut [u32]> = Left(vec![2, 3]);
for l in left.iter_mut() {
*l *= *l
}
assert_eq!(left, Left(vec![4, 9]));
let mut inner = [4, 5];
let mut right: Either<Vec<u32>, _> = Right(&mut inner[..]);
for r in right.iter_mut() {
*r *= *r
}
assert_eq!(inner, [16, 25]);
Sourcepub fn factor_into_iter(
self,
) -> IterEither<<L as IntoIterator>::IntoIter, <R as IntoIterator>::IntoIter>where
L: IntoIterator,
R: IntoIterator,
pub fn factor_into_iter(
self,
) -> IterEither<<L as IntoIterator>::IntoIter, <R as IntoIterator>::IntoIter>where
L: IntoIterator,
R: IntoIterator,
Converts an Either
of Iterator
s to be an Iterator
of Either
s
Unlike into_iter
, this does not require the
Left
and Right
iterators to have the same item type.
use either::*;
let left: Either<_, Vec<u8>> = Left(&["hello"]);
assert_eq!(left.factor_into_iter().next(), Some(Left(&"hello")));
let right: Either<&[&str], _> = Right(vec![0, 1]);
assert_eq!(right.factor_into_iter().collect::<Vec<_>>(), vec![Right(0), Right(1)]);
Sourcepub fn factor_iter(
&self,
) -> IterEither<<&L as IntoIterator>::IntoIter, <&R as IntoIterator>::IntoIter>
pub fn factor_iter( &self, ) -> IterEither<<&L as IntoIterator>::IntoIter, <&R as IntoIterator>::IntoIter>
Borrows an Either
of Iterator
s to be an Iterator
of Either
s
Unlike iter
, this does not require the
Left
and Right
iterators to have the same item type.
use either::*;
let left: Either<_, Vec<u8>> = Left(["hello"]);
assert_eq!(left.factor_iter().next(), Some(Left(&"hello")));
let right: Either<[&str; 2], _> = Right(vec![0, 1]);
assert_eq!(right.factor_iter().collect::<Vec<_>>(), vec![Right(&0), Right(&1)]);
Sourcepub fn factor_iter_mut(
&mut self,
) -> IterEither<<&mut L as IntoIterator>::IntoIter, <&mut R as IntoIterator>::IntoIter>
pub fn factor_iter_mut( &mut self, ) -> IterEither<<&mut L as IntoIterator>::IntoIter, <&mut R as IntoIterator>::IntoIter>
Mutably borrows an Either
of Iterator
s to be an Iterator
of Either
s
Unlike iter_mut
, this does not require the
Left
and Right
iterators to have the same item type.
use either::*;
let mut left: Either<_, Vec<u8>> = Left(["hello"]);
left.factor_iter_mut().for_each(|x| *x.unwrap_left() = "goodbye");
assert_eq!(left, Left(["goodbye"]));
let mut right: Either<[&str; 2], _> = Right(vec![0, 1, 2]);
right.factor_iter_mut().for_each(|x| if let Right(r) = x { *r = -*r; });
assert_eq!(right, Right(vec![0, -1, -2]));
Sourcepub fn left_or(self, other: L) -> L
pub fn left_or(self, other: L) -> L
Return left value or given value
Arguments passed to left_or
are eagerly evaluated; if you are passing
the result of a function call, it is recommended to use
left_or_else
, which is lazily evaluated.
§Examples
let left: Either<&str, &str> = Left("left");
assert_eq!(left.left_or("foo"), "left");
let right: Either<&str, &str> = Right("right");
assert_eq!(right.left_or("left"), "left");
Sourcepub fn left_or_default(self) -> Lwhere
L: Default,
pub fn left_or_default(self) -> Lwhere
L: Default,
Return left or a default
§Examples
let left: Either<String, u32> = Left("left".to_string());
assert_eq!(left.left_or_default(), "left");
let right: Either<String, u32> = Right(42);
assert_eq!(right.left_or_default(), String::default());
Sourcepub fn left_or_else<F>(self, f: F) -> Lwhere
F: FnOnce(R) -> L,
pub fn left_or_else<F>(self, f: F) -> Lwhere
F: FnOnce(R) -> L,
Returns left value or computes it from a closure
§Examples
let left: Either<String, u32> = Left("3".to_string());
assert_eq!(left.left_or_else(|_| unreachable!()), "3");
let right: Either<String, u32> = Right(3);
assert_eq!(right.left_or_else(|x| x.to_string()), "3");
Sourcepub fn right_or(self, other: R) -> R
pub fn right_or(self, other: R) -> R
Return right value or given value
Arguments passed to right_or
are eagerly evaluated; if you are passing
the result of a function call, it is recommended to use
right_or_else
, which is lazily evaluated.
§Examples
let right: Either<&str, &str> = Right("right");
assert_eq!(right.right_or("foo"), "right");
let left: Either<&str, &str> = Left("left");
assert_eq!(left.right_or("right"), "right");
Sourcepub fn right_or_default(self) -> Rwhere
R: Default,
pub fn right_or_default(self) -> Rwhere
R: Default,
Return right or a default
§Examples
let left: Either<String, u32> = Left("left".to_string());
assert_eq!(left.right_or_default(), u32::default());
let right: Either<String, u32> = Right(42);
assert_eq!(right.right_or_default(), 42);
Sourcepub fn right_or_else<F>(self, f: F) -> Rwhere
F: FnOnce(L) -> R,
pub fn right_or_else<F>(self, f: F) -> Rwhere
F: FnOnce(L) -> R,
Returns right value or computes it from a closure
§Examples
let left: Either<String, u32> = Left("3".to_string());
assert_eq!(left.right_or_else(|x| x.parse().unwrap()), 3);
let right: Either<String, u32> = Right(3);
assert_eq!(right.right_or_else(|_| unreachable!()), 3);
Sourcepub fn unwrap_left(self) -> Lwhere
R: Debug,
pub fn unwrap_left(self) -> Lwhere
R: Debug,
Sourcepub fn unwrap_right(self) -> Rwhere
L: Debug,
pub fn unwrap_right(self) -> Rwhere
L: Debug,
Sourcepub fn expect_left(self, msg: &str) -> Lwhere
R: Debug,
pub fn expect_left(self, msg: &str) -> Lwhere
R: Debug,
Sourcepub fn expect_right(self, msg: &str) -> Rwhere
L: Debug,
pub fn expect_right(self, msg: &str) -> Rwhere
L: Debug,
Sourcepub fn either_into<T>(self) -> T
pub fn either_into<T>(self) -> T
Convert the contained value into T
§Examples
// Both u16 and u32 can be converted to u64.
let left: Either<u16, u32> = Left(3u16);
assert_eq!(left.either_into::<u64>(), 3u64);
let right: Either<u16, u32> = Right(7u32);
assert_eq!(right.either_into::<u64>(), 7u64);
Source§impl<L, R> Either<Option<L>, Option<R>>
impl<L, R> Either<Option<L>, Option<R>>
Sourcepub fn factor_none(self) -> Option<Either<L, R>>
pub fn factor_none(self) -> Option<Either<L, R>>
Factors out None
from an Either
of Option
.
use either::*;
let left: Either<_, Option<String>> = Left(Some(vec![0]));
assert_eq!(left.factor_none(), Some(Left(vec![0])));
let right: Either<Option<Vec<u8>>, _> = Right(Some(String::new()));
assert_eq!(right.factor_none(), Some(Right(String::new())));
Source§impl<L, R, E> Either<Result<L, E>, Result<R, E>>
impl<L, R, E> Either<Result<L, E>, Result<R, E>>
Sourcepub fn factor_err(self) -> Result<Either<L, R>, E>
pub fn factor_err(self) -> Result<Either<L, R>, E>
Factors out a homogenous type from an Either
of Result
.
Here, the homogeneous type is the Err
type of the Result
.
use either::*;
let left: Either<_, Result<String, u32>> = Left(Ok(vec![0]));
assert_eq!(left.factor_err(), Ok(Left(vec![0])));
let right: Either<Result<Vec<u8>, u32>, _> = Right(Ok(String::new()));
assert_eq!(right.factor_err(), Ok(Right(String::new())));
Source§impl<T, L, R> Either<Result<T, L>, Result<T, R>>
impl<T, L, R> Either<Result<T, L>, Result<T, R>>
Sourcepub fn factor_ok(self) -> Result<T, Either<L, R>>
pub fn factor_ok(self) -> Result<T, Either<L, R>>
Factors out a homogenous type from an Either
of Result
.
Here, the homogeneous type is the Ok
type of the Result
.
use either::*;
let left: Either<_, Result<u32, String>> = Left(Err(vec![0]));
assert_eq!(left.factor_ok(), Err(Left(vec![0])));
let right: Either<Result<u32, Vec<u8>>, _> = Right(Err(String::new()));
assert_eq!(right.factor_ok(), Err(Right(String::new())));
Source§impl<T, L, R> Either<(T, L), (T, R)>
impl<T, L, R> Either<(T, L), (T, R)>
Sourcepub fn factor_first(self) -> (T, Either<L, R>)
pub fn factor_first(self) -> (T, Either<L, R>)
Factor out a homogeneous type from an either of pairs.
Here, the homogeneous type is the first element of the pairs.
use either::*;
let left: Either<_, (u32, String)> = Left((123, vec![0]));
assert_eq!(left.factor_first().0, 123);
let right: Either<(u32, Vec<u8>), _> = Right((123, String::new()));
assert_eq!(right.factor_first().0, 123);
Source§impl<T, L, R> Either<(L, T), (R, T)>
impl<T, L, R> Either<(L, T), (R, T)>
Sourcepub fn factor_second(self) -> (Either<L, R>, T)
pub fn factor_second(self) -> (Either<L, R>, T)
Factor out a homogeneous type from an either of pairs.
Here, the homogeneous type is the second element of the pairs.
use either::*;
let left: Either<_, (String, u32)> = Left((vec![0], 123));
assert_eq!(left.factor_second().1, 123);
let right: Either<(Vec<u8>, u32), _> = Right((String::new(), 123));
assert_eq!(right.factor_second().1, 123);
Source§impl<T> Either<T, T>
impl<T> Either<T, T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Extract the value of an either over two equivalent types.
use either::*;
let left: Either<_, u32> = Left(123);
assert_eq!(left.into_inner(), 123);
let right: Either<u32, _> = Right(123);
assert_eq!(right.into_inner(), 123);
Source§impl<L, R> Either<&L, &R>
impl<L, R> Either<&L, &R>
Trait Implementations§
Source§impl<L, R, Target> AsMut<Target> for Either<L, R>
impl<L, R, Target> AsMut<Target> for Either<L, R>
Source§fn as_mut(&mut self) -> &mut Target
fn as_mut(&mut self) -> &mut Target
Source§impl<L, R> DoubleEndedIterator for Either<L, R>
impl<L, R> DoubleEndedIterator for Either<L, R>
Source§fn next_back(&mut self) -> Option<<Either<L, R> as Iterator>::Item>
fn next_back(&mut self) -> Option<<Either<L, R> as Iterator>::Item>
Source§fn nth_back(&mut self, n: usize) -> Option<<Either<L, R> as Iterator>::Item>
fn nth_back(&mut self, n: usize) -> Option<<Either<L, R> as Iterator>::Item>
n
th element from the end of the iterator. Read moreSource§fn rfold<Acc, G>(self, init: Acc, f: G) -> Acc
fn rfold<Acc, G>(self, init: Acc, f: G) -> Acc
Source§fn rfind<P>(&mut self, predicate: P) -> Option<<Either<L, R> as Iterator>::Item>
fn rfind<P>(&mut self, predicate: P) -> Option<<Either<L, R> as Iterator>::Item>
Source§impl<L, R> ExactSizeIterator for Either<L, R>
impl<L, R> ExactSizeIterator for Either<L, R>
Source§impl<L, R, A> Extend<A> for Either<L, R>
impl<L, R, A> Extend<A> for Either<L, R>
Source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = A>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = A>,
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<L, R> From<Result<R, L>> for Either<L, R>
impl<L, R> From<Result<R, L>> for Either<L, R>
Convert from Result
to Either
with Ok => Right
and Err => Left
.
Source§impl<L, R, A, B> FromParallelIterator<Either<L, R>> for (A, B)
impl<L, R, A, B> FromParallelIterator<Either<L, R>> for (A, B)
Source§fn from_par_iter<I>(pi: I) -> Selfwhere
I: IntoParallelIterator<Item = Either<L, R>>,
fn from_par_iter<I>(pi: I) -> Selfwhere
I: IntoParallelIterator<Item = Either<L, R>>,
par_iter
. Read moreSource§impl<L, R> IndexedParallelIterator for Either<L, R>
impl<L, R> IndexedParallelIterator for Either<L, R>
Source§fn drive<C>(self, consumer: C) -> C::Result
fn drive<C>(self, consumer: C) -> C::Result
Source§fn len(&self) -> usize
fn len(&self) -> usize
Source§fn with_producer<CB>(self, callback: CB) -> CB::Outputwhere
CB: ProducerCallback<Self::Item>,
fn with_producer<CB>(self, callback: CB) -> CB::Outputwhere
CB: ProducerCallback<Self::Item>,
Source§fn by_exponential_blocks(self) -> ExponentialBlocks<Self>
fn by_exponential_blocks(self) -> ExponentialBlocks<Self>
Source§fn by_uniform_blocks(self, block_size: usize) -> UniformBlocks<Self>
fn by_uniform_blocks(self, block_size: usize) -> UniformBlocks<Self>
Source§fn collect_into_vec(self, target: &mut Vec<Self::Item>)
fn collect_into_vec(self, target: &mut Vec<Self::Item>)
Source§fn unzip_into_vecs<A, B>(self, left: &mut Vec<A>, right: &mut Vec<B>)
fn unzip_into_vecs<A, B>(self, left: &mut Vec<A>, right: &mut Vec<B>)
Source§fn zip<Z>(self, zip_op: Z) -> Zip<Self, Z::Iter>
fn zip<Z>(self, zip_op: Z) -> Zip<Self, Z::Iter>
(A, B)
, where the items A
are from
this iterator and B
are from the iterator given as argument.
Like the zip
method on ordinary iterators, if the two
iterators are of unequal length, you only get the items they
have in common. Read moreSource§fn zip_eq<Z>(self, zip_op: Z) -> ZipEq<Self, Z::Iter>
fn zip_eq<Z>(self, zip_op: Z) -> ZipEq<Self, Z::Iter>
Zip
, but requires that both iterators have the same length. Read moreSource§fn interleave<I>(self, other: I) -> Interleave<Self, I::Iter>where
I: IntoParallelIterator<Item = Self::Item>,
I::Iter: IndexedParallelIterator<Item = Self::Item>,
fn interleave<I>(self, other: I) -> Interleave<Self, I::Iter>where
I: IntoParallelIterator<Item = Self::Item>,
I::Iter: IndexedParallelIterator<Item = Self::Item>,
Source§fn interleave_shortest<I>(self, other: I) -> InterleaveShortest<Self, I::Iter>where
I: IntoParallelIterator<Item = Self::Item>,
I::Iter: IndexedParallelIterator<Item = Self::Item>,
fn interleave_shortest<I>(self, other: I) -> InterleaveShortest<Self, I::Iter>where
I: IntoParallelIterator<Item = Self::Item>,
I::Iter: IndexedParallelIterator<Item = Self::Item>,
Source§fn chunks(self, chunk_size: usize) -> Chunks<Self>
fn chunks(self, chunk_size: usize) -> Chunks<Self>
Source§fn fold_chunks<T, ID, F>(
self,
chunk_size: usize,
identity: ID,
fold_op: F,
) -> FoldChunks<Self, ID, F>
fn fold_chunks<T, ID, F>( self, chunk_size: usize, identity: ID, fold_op: F, ) -> FoldChunks<Self, ID, F>
Source§fn fold_chunks_with<T, F>(
self,
chunk_size: usize,
init: T,
fold_op: F,
) -> FoldChunksWith<Self, T, F>
fn fold_chunks_with<T, F>( self, chunk_size: usize, init: T, fold_op: F, ) -> FoldChunksWith<Self, T, F>
Source§fn cmp<I>(self, other: I) -> Orderingwhere
I: IntoParallelIterator<Item = Self::Item>,
I::Iter: IndexedParallelIterator,
Self::Item: Ord,
fn cmp<I>(self, other: I) -> Orderingwhere
I: IntoParallelIterator<Item = Self::Item>,
I::Iter: IndexedParallelIterator,
Self::Item: Ord,
ParallelIterator
with those of
another. Read moreSource§fn partial_cmp<I>(self, other: I) -> Option<Ordering>
fn partial_cmp<I>(self, other: I) -> Option<Ordering>
ParallelIterator
with those of
another. Read moreSource§fn eq<I>(self, other: I) -> bool
fn eq<I>(self, other: I) -> bool
ParallelIterator
are equal to those of anotherSource§fn ne<I>(self, other: I) -> bool
fn ne<I>(self, other: I) -> bool
ParallelIterator
are unequal to those of anotherSource§fn lt<I>(self, other: I) -> bool
fn lt<I>(self, other: I) -> bool
ParallelIterator
are lexicographically less than those of another.Source§fn le<I>(self, other: I) -> bool
fn le<I>(self, other: I) -> bool
ParallelIterator
are less or equal to those of another.Source§fn gt<I>(self, other: I) -> bool
fn gt<I>(self, other: I) -> bool
ParallelIterator
are lexicographically greater than those of another.Source§fn ge<I>(self, other: I) -> bool
fn ge<I>(self, other: I) -> bool
ParallelIterator
are less or equal to those of another.Source§fn step_by(self, step: usize) -> StepBy<Self>
fn step_by(self, step: usize) -> StepBy<Self>
Source§fn skip(self, n: usize) -> Skip<Self>
fn skip(self, n: usize) -> Skip<Self>
n
elements. Read moreSource§fn take(self, n: usize) -> Take<Self>
fn take(self, n: usize) -> Take<Self>
n
elements. Read moreSource§fn position_any<P>(self, predicate: P) -> Option<usize>
fn position_any<P>(self, predicate: P) -> Option<usize>
ParallelIterator::find_any
, the parallel search will not
necessarily find the first match, and once a match is
found we’ll attempt to stop processing any more. Read moreSource§fn position_first<P>(self, predicate: P) -> Option<usize>
fn position_first<P>(self, predicate: P) -> Option<usize>
Source§fn position_last<P>(self, predicate: P) -> Option<usize>
fn position_last<P>(self, predicate: P) -> Option<usize>
Source§fn positions<P>(self, predicate: P) -> Positions<Self, P>
fn positions<P>(self, predicate: P) -> Positions<Self, P>
Source§fn rev(self) -> Rev<Self>
fn rev(self) -> Rev<Self>
Source§fn with_min_len(self, min: usize) -> MinLen<Self>
fn with_min_len(self, min: usize) -> MinLen<Self>
Source§fn with_max_len(self, max: usize) -> MaxLen<Self>
fn with_max_len(self, max: usize) -> MaxLen<Self>
with_min_len()
.
For example, given min=10 and max=15, a length of 16 will not be
split any further. Read moreSource§impl<L, R> Into<Result<R, L>> for Either<L, R>
impl<L, R> Into<Result<R, L>> for Either<L, R>
Convert from Either
to Result
with Right => Ok
and Left => Err
.
Source§impl<L, R> Iterator for Either<L, R>
impl<L, R> Iterator for Either<L, R>
Either<L, R>
is an iterator if both L
and R
are iterators.
Source§fn next(&mut self) -> Option<<Either<L, R> as Iterator>::Item>
fn next(&mut self) -> Option<<Either<L, R> as Iterator>::Item>
Source§fn size_hint(&self) -> (usize, Option<usize>)
fn size_hint(&self) -> (usize, Option<usize>)
Source§fn fold<Acc, G>(self, init: Acc, f: G) -> Acc
fn fold<Acc, G>(self, init: Acc, f: G) -> Acc
Source§fn count(self) -> usize
fn count(self) -> usize
Source§fn last(self) -> Option<<Either<L, R> as Iterator>::Item>
fn last(self) -> Option<<Either<L, R> as Iterator>::Item>
Source§fn nth(&mut self, n: usize) -> Option<<Either<L, R> as Iterator>::Item>
fn nth(&mut self, n: usize) -> Option<<Either<L, R> as Iterator>::Item>
n
th element of the iterator. Read moreSource§fn partition<B, F>(self, f: F) -> (B, B)
fn partition<B, F>(self, f: F) -> (B, B)
Source§fn all<F>(&mut self, f: F) -> bool
fn all<F>(&mut self, f: F) -> bool
Source§fn any<F>(&mut self, f: F) -> bool
fn any<F>(&mut self, f: F) -> bool
Source§fn find<P>(&mut self, predicate: P) -> Option<<Either<L, R> as Iterator>::Item>
fn find<P>(&mut self, predicate: P) -> Option<<Either<L, R> as Iterator>::Item>
Source§fn find_map<B, F>(&mut self, f: F) -> Option<B>
fn find_map<B, F>(&mut self, f: F) -> Option<B>
Source§fn position<P>(&mut self, predicate: P) -> Option<usize>
fn position<P>(&mut self, predicate: P) -> Option<usize>
Source§fn next_chunk<const N: usize>(
&mut self,
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
fn next_chunk<const N: usize>(
&mut self,
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
iter_next_chunk
)N
values. Read moreSource§fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
iter_advance_by
)n
elements. Read more1.28.0 · Source§fn step_by(self, step: usize) -> StepBy<Self>where
Self: Sized,
fn step_by(self, step: usize) -> StepBy<Self>where
Self: Sized,
1.0.0 · Source§fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter>
fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter>
1.0.0 · Source§fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter>where
Self: Sized,
U: IntoIterator,
fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter>where
Self: Sized,
U: IntoIterator,
Source§fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
iter_intersperse
)separator
between adjacent
items of the original iterator. Read moreSource§fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
iter_intersperse
)separator
between adjacent items of the original iterator. Read more1.0.0 · Source§fn map<B, F>(self, f: F) -> Map<Self, F>
fn map<B, F>(self, f: F) -> Map<Self, F>
1.0.0 · Source§fn filter<P>(self, predicate: P) -> Filter<Self, P>
fn filter<P>(self, predicate: P) -> Filter<Self, P>
1.0.0 · Source§fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
1.0.0 · Source§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
1.0.0 · Source§fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
1.0.0 · Source§fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
1.57.0 · Source§fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
1.0.0 · Source§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
n
elements. Read more1.0.0 · Source§fn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where
Self: Sized,
n
elements, or fewer
if the underlying iterator ends sooner. Read more1.0.0 · Source§fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
1.29.0 · Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N>
fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N>
iter_map_windows
)f
for each contiguous window of size N
over
self
and returns an iterator over the outputs of f
. Like slice::windows()
,
the windows during mapping overlap as well. Read more1.0.0 · Source§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Source§fn try_collect<B>(
&mut self,
) -> <<Self::Item as Try>::Residual as Residual<B>>::TryType
fn try_collect<B>( &mut self, ) -> <<Self::Item as Try>::Residual as Residual<B>>::TryType
iterator_try_collect
)Source§fn collect_into<E>(self, collection: &mut E) -> &mut E
fn collect_into<E>(self, collection: &mut E) -> &mut E
iter_collect_into
)Source§fn partition_in_place<'a, T, P>(self, predicate: P) -> usize
fn partition_in_place<'a, T, P>(self, predicate: P) -> usize
iter_partition_in_place
)true
precede all those that return false
.
Returns the number of true
elements found. Read moreSource§fn is_partitioned<P>(self, predicate: P) -> bool
fn is_partitioned<P>(self, predicate: P) -> bool
iter_is_partitioned
)true
precede all those that return false
. Read more1.27.0 · Source§fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R
fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R
1.27.0 · Source§fn try_for_each<F, R>(&mut self, f: F) -> R
fn try_for_each<F, R>(&mut self, f: F) -> R
1.51.0 · Source§fn reduce<F>(self, f: F) -> Option<Self::Item>
fn reduce<F>(self, f: F) -> Option<Self::Item>
Source§fn try_reduce<R>(
&mut self,
f: impl FnMut(Self::Item, Self::Item) -> R,
) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryType
fn try_reduce<R>( &mut self, f: impl FnMut(Self::Item, Self::Item) -> R, ) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryType
iterator_try_reduce
)Source§fn try_find<R>(
&mut self,
f: impl FnMut(&Self::Item) -> R,
) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryType
fn try_find<R>( &mut self, f: impl FnMut(&Self::Item) -> R, ) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryType
try_find
)1.0.0 · Source§fn rposition<P>(&mut self, predicate: P) -> Option<usize>
fn rposition<P>(&mut self, predicate: P) -> Option<usize>
1.0.0 · Source§fn max(self) -> Option<Self::Item>
fn max(self) -> Option<Self::Item>
1.0.0 · Source§fn min(self) -> Option<Self::Item>
fn min(self) -> Option<Self::Item>
1.6.0 · Source§fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>
fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>
1.15.0 · Source§fn max_by<F>(self, compare: F) -> Option<Self::Item>
fn max_by<F>(self, compare: F) -> Option<Self::Item>
1.6.0 · Source§fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>
fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>
1.15.0 · Source§fn min_by<F>(self, compare: F) -> Option<Self::Item>
fn min_by<F>(self, compare: F) -> Option<Self::Item>
1.0.0 · Source§fn rev(self) -> Rev<Self>where
Self: Sized + DoubleEndedIterator,
fn rev(self) -> Rev<Self>where
Self: Sized + DoubleEndedIterator,
1.0.0 · Source§fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
1.36.0 · Source§fn copied<'a, T>(self) -> Copied<Self>
fn copied<'a, T>(self) -> Copied<Self>
Source§fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>where
Self: Sized,
fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>where
Self: Sized,
iter_array_chunks
)N
elements of the iterator at a time. Read more1.11.0 · Source§fn product<P>(self) -> P
fn product<P>(self) -> P
Source§fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
iter_order_by
)Iterator
with those
of another with respect to the specified comparison function. Read more1.5.0 · Source§fn partial_cmp<I>(self, other: I) -> Option<Ordering>
fn partial_cmp<I>(self, other: I) -> Option<Ordering>
PartialOrd
elements of
this Iterator
with those of another. The comparison works like short-circuit
evaluation, returning a result without comparing the remaining elements.
As soon as an order can be determined, the evaluation stops and a result is returned. Read moreSource§fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
iter_order_by
)Iterator
with those
of another with respect to the specified comparison function. Read moreSource§fn eq_by<I, F>(self, other: I, eq: F) -> bool
fn eq_by<I, F>(self, other: I, eq: F) -> bool
iter_order_by
)1.5.0 · Source§fn lt<I>(self, other: I) -> bool
fn lt<I>(self, other: I) -> bool
Iterator
are lexicographically
less than those of another. Read more1.5.0 · Source§fn le<I>(self, other: I) -> bool
fn le<I>(self, other: I) -> bool
Iterator
are lexicographically
less or equal to those of another. Read more1.5.0 · Source§fn gt<I>(self, other: I) -> bool
fn gt<I>(self, other: I) -> bool
Iterator
are lexicographically
greater than those of another. Read more1.5.0 · Source§fn ge<I>(self, other: I) -> bool
fn ge<I>(self, other: I) -> bool
Iterator
are lexicographically
greater than or equal to those of another. Read more1.82.0 · Source§fn is_sorted(self) -> bool
fn is_sorted(self) -> bool
1.82.0 · Source§fn is_sorted_by<F>(self, compare: F) -> bool
fn is_sorted_by<F>(self, compare: F) -> bool
1.82.0 · Source§fn is_sorted_by_key<F, K>(self, f: F) -> bool
fn is_sorted_by_key<F, K>(self, f: F) -> bool
Source§impl<L, R> Ord for Either<L, R>
impl<L, R> Ord for Either<L, R>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<L, R, A, B> ParallelExtend<Either<L, R>> for (A, B)
impl<L, R, A, B> ParallelExtend<Either<L, R>> for (A, B)
Source§fn par_extend<I>(&mut self, pi: I)where
I: IntoParallelIterator<Item = Either<L, R>>,
fn par_extend<I>(&mut self, pi: I)where
I: IntoParallelIterator<Item = Either<L, R>>,
par_iter
. Read moreSource§impl<L, R, T> ParallelExtend<T> for Either<L, R>
impl<L, R, T> ParallelExtend<T> for Either<L, R>
Either<L, R>
can be extended if both L
and R
are parallel extendable.
Source§fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = T>,
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = T>,
par_iter
. Read moreSource§impl<L, R> ParallelIterator for Either<L, R>
impl<L, R> ParallelIterator for Either<L, R>
Either<L, R>
is a parallel iterator if both L
and R
are parallel iterators.
Source§type Item = <L as ParallelIterator>::Item
type Item = <L as ParallelIterator>::Item
for_each
method, this is the type of
item that your closure will be invoked with.Source§fn drive_unindexed<C>(self, consumer: C) -> C::Resultwhere
C: UnindexedConsumer<Self::Item>,
fn drive_unindexed<C>(self, consumer: C) -> C::Resultwhere
C: UnindexedConsumer<Self::Item>,
Source§fn opt_len(&self) -> Option<usize>
fn opt_len(&self) -> Option<usize>
Source§fn for_each<OP>(self, op: OP)
fn for_each<OP>(self, op: OP)
OP
on each item produced by the iterator, in parallel. Read moreSource§fn for_each_with<OP, T>(self, init: T, op: OP)
fn for_each_with<OP, T>(self, init: T, op: OP)
Source§fn for_each_init<OP, INIT, T>(self, init: INIT, op: OP)
fn for_each_init<OP, INIT, T>(self, init: INIT, op: OP)
OP
on a value returned by init
with each item produced by
the iterator, in parallel. Read moreSource§fn try_for_each<OP, R>(self, op: OP) -> R
fn try_for_each<OP, R>(self, op: OP) -> R
OP
on each item produced by the iterator, in parallel. Read moreSource§fn try_for_each_with<OP, T, R>(self, init: T, op: OP) -> R
fn try_for_each_with<OP, T, R>(self, init: T, op: OP) -> R
OP
on the given init
value with each item
produced by the iterator, in parallel. Read moreSource§fn try_for_each_init<OP, INIT, T, R>(self, init: INIT, op: OP) -> R
fn try_for_each_init<OP, INIT, T, R>(self, init: INIT, op: OP) -> R
OP
on a value returned by init
with each item
produced by the iterator, in parallel. Read moreSource§fn map<F, R>(self, map_op: F) -> Map<Self, F>
fn map<F, R>(self, map_op: F) -> Map<Self, F>
map_op
to each item of this iterator, producing a new
iterator with the results. Read moreSource§fn map_with<F, T, R>(self, init: T, map_op: F) -> MapWith<Self, T, F>
fn map_with<F, T, R>(self, init: T, map_op: F) -> MapWith<Self, T, F>
map_op
to the given init
value with each item of this
iterator, producing a new iterator with the results. Read moreSource§fn map_init<F, INIT, T, R>(
self,
init: INIT,
map_op: F,
) -> MapInit<Self, INIT, F>
fn map_init<F, INIT, T, R>( self, init: INIT, map_op: F, ) -> MapInit<Self, INIT, F>
map_op
to a value returned by init
with each item of this
iterator, producing a new iterator with the results. Read moreSource§fn inspect<OP>(self, inspect_op: OP) -> Inspect<Self, OP>
fn inspect<OP>(self, inspect_op: OP) -> Inspect<Self, OP>
inspect_op
to a reference to each item of this iterator,
producing a new iterator passing through the original items. This is
often useful for debugging to see what’s happening in iterator stages. Read moreSource§fn update<F>(self, update_op: F) -> Update<Self, F>
fn update<F>(self, update_op: F) -> Update<Self, F>
Source§fn filter<P>(self, filter_op: P) -> Filter<Self, P>
fn filter<P>(self, filter_op: P) -> Filter<Self, P>
filter_op
to each item of this iterator, producing a new
iterator with only the items that gave true
results. Read moreSource§fn filter_map<P, R>(self, filter_op: P) -> FilterMap<Self, P>
fn filter_map<P, R>(self, filter_op: P) -> FilterMap<Self, P>
filter_op
to each item of this iterator to get an Option
,
producing a new iterator with only the items from Some
results. Read moreSource§fn flat_map<F, PI>(self, map_op: F) -> FlatMap<Self, F>
fn flat_map<F, PI>(self, map_op: F) -> FlatMap<Self, F>
map_op
to each item of this iterator to get nested parallel iterators,
producing a new parallel iterator that flattens these back into one. Read moreSource§fn flat_map_iter<F, SI>(self, map_op: F) -> FlatMapIter<Self, F>
fn flat_map_iter<F, SI>(self, map_op: F) -> FlatMapIter<Self, F>
map_op
to each item of this iterator to get nested serial iterators,
producing a new parallel iterator that flattens these back into one. Read moreSource§fn flatten(self) -> Flatten<Self>where
Self::Item: IntoParallelIterator,
fn flatten(self) -> Flatten<Self>where
Self::Item: IntoParallelIterator,
Item
s into one large iterator. Read moreSource§fn flatten_iter(self) -> FlattenIter<Self>
fn flatten_iter(self) -> FlattenIter<Self>
Item
s into one large iterator. Read moreSource§fn reduce<OP, ID>(self, identity: ID, op: OP) -> Self::Item
fn reduce<OP, ID>(self, identity: ID, op: OP) -> Self::Item
op
.
The argument identity
should be a closure that can produce
“identity” value which may be inserted into the sequence as
needed to create opportunities for parallel execution. So, for
example, if you are doing a summation, then identity()
ought
to produce something that represents the zero for your type
(but consider just calling sum()
in that case). Read moreSource§fn reduce_with<OP>(self, op: OP) -> Option<Self::Item>
fn reduce_with<OP>(self, op: OP) -> Option<Self::Item>
op
.
If the iterator is empty, None
is returned; otherwise,
Some
is returned. Read moreSource§fn try_reduce<T, OP, ID>(self, identity: ID, op: OP) -> Self::Item
fn try_reduce<T, OP, ID>(self, identity: ID, op: OP) -> Self::Item
Source§fn try_reduce_with<T, OP>(self, op: OP) -> Option<Self::Item>
fn try_reduce_with<T, OP>(self, op: OP) -> Option<Self::Item>
op
. Read moreSource§fn fold<T, ID, F>(self, identity: ID, fold_op: F) -> Fold<Self, ID, F>
fn fold<T, ID, F>(self, identity: ID, fold_op: F) -> Fold<Self, ID, F>
22 3 77 89 46
. If
you used sequential fold to add them (fold(0, |a,b| a+b)
,
you would wind up first adding 0 + 22, then 22 + 3, then 25 +
77, and so forth. The parallel fold works similarly except
that it first breaks up your list into sublists, and hence
instead of yielding up a single sum at the end, it yields up
multiple sums. The number of results is nondeterministic, as
is the point where the breaks occur. Read moreSource§fn fold_with<F, T>(self, init: T, fold_op: F) -> FoldWith<Self, T, F>
fn fold_with<F, T>(self, init: T, fold_op: F) -> FoldWith<Self, T, F>
fold_op
to the given init
value with each item of this
iterator, finally producing the value for further use. Read moreSource§fn try_fold<T, R, ID, F>(
self,
identity: ID,
fold_op: F,
) -> TryFold<Self, R, ID, F>
fn try_fold<T, R, ID, F>( self, identity: ID, fold_op: F, ) -> TryFold<Self, R, ID, F>
Source§fn try_fold_with<F, T, R>(self, init: T, fold_op: F) -> TryFoldWith<Self, R, F>
fn try_fold_with<F, T, R>(self, init: T, fold_op: F) -> TryFoldWith<Self, R, F>
init
value. Read moreSource§fn min(self) -> Option<Self::Item>
fn min(self) -> Option<Self::Item>
None
is returned; otherwise, Some(min)
is returned. Read moreSource§fn min_by<F>(self, f: F) -> Option<Self::Item>
fn min_by<F>(self, f: F) -> Option<Self::Item>
None
is
returned; otherwise, Some(min)
is returned. Read moreSource§fn min_by_key<K, F>(self, f: F) -> Option<Self::Item>
fn min_by_key<K, F>(self, f: F) -> Option<Self::Item>
None
is returned;
otherwise, Some(item)
is returned. Read moreSource§fn max(self) -> Option<Self::Item>
fn max(self) -> Option<Self::Item>
None
is returned; otherwise, Some(max)
is returned. Read moreSource§fn max_by<F>(self, f: F) -> Option<Self::Item>
fn max_by<F>(self, f: F) -> Option<Self::Item>
None
is
returned; otherwise, Some(max)
is returned. Read moreSource§fn max_by_key<K, F>(self, f: F) -> Option<Self::Item>
fn max_by_key<K, F>(self, f: F) -> Option<Self::Item>
None
is returned;
otherwise, Some(item)
is returned. Read moreSource§fn chain<C>(self, chain: C) -> Chain<Self, C::Iter>where
C: IntoParallelIterator<Item = Self::Item>,
fn chain<C>(self, chain: C) -> Chain<Self, C::Iter>where
C: IntoParallelIterator<Item = Self::Item>,
Source§fn find_any<P>(self, predicate: P) -> Option<Self::Item>
fn find_any<P>(self, predicate: P) -> Option<Self::Item>
find
on sequential iterators but
the item returned may not be the first one in the parallel
sequence which matches, since we search the entire sequence in parallel. Read moreSource§fn find_first<P>(self, predicate: P) -> Option<Self::Item>
fn find_first<P>(self, predicate: P) -> Option<Self::Item>
Source§fn find_last<P>(self, predicate: P) -> Option<Self::Item>
fn find_last<P>(self, predicate: P) -> Option<Self::Item>
Source§fn find_map_any<P, R>(self, predicate: P) -> Option<R>
fn find_map_any<P, R>(self, predicate: P) -> Option<R>
Source§fn find_map_first<P, R>(self, predicate: P) -> Option<R>
fn find_map_first<P, R>(self, predicate: P) -> Option<R>
Source§fn find_map_last<P, R>(self, predicate: P) -> Option<R>
fn find_map_last<P, R>(self, predicate: P) -> Option<R>
Source§fn any<P>(self, predicate: P) -> bool
fn any<P>(self, predicate: P) -> bool
Source§fn all<P>(self, predicate: P) -> bool
fn all<P>(self, predicate: P) -> bool
Source§fn while_some<T>(self) -> WhileSome<Self>
fn while_some<T>(self) -> WhileSome<Self>
Some
items of this iterator, halting
as soon as any None
is found. Read moreSource§fn panic_fuse(self) -> PanicFuse<Self>
fn panic_fuse(self) -> PanicFuse<Self>
Source§fn collect<C>(self) -> Cwhere
C: FromParallelIterator<Self::Item>,
fn collect<C>(self) -> Cwhere
C: FromParallelIterator<Self::Item>,
Source§fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)where
Self: ParallelIterator<Item = (A, B)>,
FromA: Default + Send + ParallelExtend<A>,
FromB: Default + Send + ParallelExtend<B>,
A: Send,
B: Send,
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)where
Self: ParallelIterator<Item = (A, B)>,
FromA: Default + Send + ParallelExtend<A>,
FromB: Default + Send + ParallelExtend<B>,
A: Send,
B: Send,
ParallelExtend
containers. Read moreSource§fn partition<A, B, P>(self, predicate: P) -> (A, B)
fn partition<A, B, P>(self, predicate: P) -> (A, B)
ParallelExtend
containers. Items for which the predicate
returns
true go into the first container, and the rest go into the second. Read moreSource§fn partition_map<A, B, P, L, R>(self, predicate: P) -> (A, B)
fn partition_map<A, B, P, L, R>(self, predicate: P) -> (A, B)
ParallelExtend
containers. Either::Left
items go into
the first container, and Either::Right
items go into the second. Read moreSource§fn intersperse(self, element: Self::Item) -> Intersperse<Self>
fn intersperse(self, element: Self::Item) -> Intersperse<Self>
Source§fn take_any(self, n: usize) -> TakeAny<Self>
fn take_any(self, n: usize) -> TakeAny<Self>
n
elements from anywhere in the original iterator. Read moreSource§fn skip_any(self, n: usize) -> SkipAny<Self>
fn skip_any(self, n: usize) -> SkipAny<Self>
n
elements from anywhere in the original iterator. Read moreSource§fn take_any_while<P>(self, predicate: P) -> TakeAnyWhile<Self, P>
fn take_any_while<P>(self, predicate: P) -> TakeAnyWhile<Self, P>
predicate
returns false
. Read moreSource§fn skip_any_while<P>(self, predicate: P) -> SkipAnyWhile<Self, P>
fn skip_any_while<P>(self, predicate: P) -> SkipAnyWhile<Self, P>
predicate
returns false
. Read moreSource§fn collect_vec_list(self) -> LinkedList<Vec<Self::Item>>
fn collect_vec_list(self) -> LinkedList<Vec<Self::Item>>
Source§impl<L, R> PartialOrd for Either<L, R>where
L: PartialOrd,
R: PartialOrd,
impl<L, R> PartialOrd for Either<L, R>where
L: PartialOrd,
R: PartialOrd,
impl<L, R> Copy for Either<L, R>
impl<L, R> Eq for Either<L, R>
impl<L, R> FusedIterator for Either<L, R>
impl<L, R> StructuralPartialEq for Either<L, R>
Auto Trait Implementations§
impl<L, R> Freeze for Either<L, R>
impl<L, R> RefUnwindSafe for Either<L, R>where
L: RefUnwindSafe,
R: RefUnwindSafe,
impl<L, R> Send for Either<L, R>
impl<L, R> Sync for Either<L, R>
impl<L, R> Unpin for Either<L, R>
impl<L, R> UnwindSafe for Either<L, R>where
L: UnwindSafe,
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Source§impl<I> IntoIterator for Iwhere
I: Iterator,
impl<I> IntoIterator for Iwhere
I: Iterator,
Source§impl<T> IntoParallelIterator for Twhere
T: ParallelIterator,
impl<T> IntoParallelIterator for Twhere
T: ParallelIterator,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.