std only.Requires crate feature std.
std only.Requires crate feature std.
std only.Requires crate feature std.
std only.Requires crate feature std.
std only.Requires crate feature std.
std only.Requires crate feature std.
std only.Requires crate feature \"std\"
Read methods, if empty. Read moreamount of additional bytes from the internal buffer as having been read.\nSubsequent calls to read only return bytes that have not been marked as read. Read more0xA byte) is reached, and append\nthem to the provided String buffer. Read morebuf_read_has_data_left)read. Read morebyte or EOF is reached. Read morenth element from the end of the iterator. Read moreReturn true if the value is the Left variant.
use either::*;\n\nlet values = [Left(1), Right(\"the right value\")];\nassert_eq!(values[0].is_left(), true);\nassert_eq!(values[1].is_left(), false);Return true if the value is the Right variant.
use either::*;\n\nlet values = [Left(1), Right(\"the right value\")];\nassert_eq!(values[0].is_right(), false);\nassert_eq!(values[1].is_right(), true);Convert the left side of Either<L, R> to an Option<L>.
use either::*;\n\nlet left: Either<_, ()> = Left(\"some value\");\nassert_eq!(left.left(), Some(\"some value\"));\n\nlet right: Either<(), _> = Right(321);\nassert_eq!(right.left(), None);Convert the right side of Either<L, R> to an Option<R>.
use either::*;\n\nlet left: Either<_, ()> = Left(\"some value\");\nassert_eq!(left.right(), None);\n\nlet right: Either<(), _> = Right(321);\nassert_eq!(right.right(), Some(321));Convert &Either<L, R> to Either<&L, &R>.
use either::*;\n\nlet left: Either<_, ()> = Left(\"some value\");\nassert_eq!(left.as_ref(), Left(&\"some value\"));\n\nlet right: Either<(), _> = Right(\"some value\");\nassert_eq!(right.as_ref(), Right(&\"some value\"));Convert &mut Either<L, R> to Either<&mut L, &mut R>.
use either::*;\n\nfn mutate_left(value: &mut Either<u32, u32>) {\n if let Some(l) = value.as_mut().left() {\n *l = 999;\n }\n}\n\nlet mut left = Left(123);\nlet mut right = Right(123);\nmutate_left(&mut left);\nmutate_left(&mut right);\nassert_eq!(left, Left(999));\nassert_eq!(right, Right(123));Convert Pin<&Either<L, R>> to Either<Pin<&L>, Pin<&R>>,\npinned projections of the inner variants.
Convert Pin<&mut Either<L, R>> to Either<Pin<&mut L>, Pin<&mut R>>,\npinned projections of the inner variants.
Convert Either<L, R> to Either<R, L>.
use either::*;\n\nlet left: Either<_, ()> = Left(123);\nassert_eq!(left.flip(), Right(123));\n\nlet right: Either<(), _> = Right(\"some value\");\nassert_eq!(right.flip(), Left(\"some value\"));Apply the function f on the value in the Left variant if it is present rewrapping the\nresult in Left.
use either::*;\n\nlet left: Either<_, u32> = Left(123);\nassert_eq!(left.map_left(|x| x * 2), Left(246));\n\nlet right: Either<u32, _> = Right(123);\nassert_eq!(right.map_left(|x| x * 2), Right(123));Apply the function f on the value in the Right variant if it is present rewrapping the\nresult in Right.
use either::*;\n\nlet left: Either<_, u32> = Left(123);\nassert_eq!(left.map_right(|x| x * 2), Left(123));\n\nlet right: Either<u32, _> = Right(123);\nassert_eq!(right.map_right(|x| x * 2), Right(246));Apply the functions f and g to the Left and Right variants\nrespectively. This is equivalent to\nbimap\nin functional programming.
use either::*;\n\nlet f = |s: String| s.len();\nlet g = |u: u8| u.to_string();\n\nlet left: Either<String, u8> = Left(\"loopy\".into());\nassert_eq!(left.map_either(f, g), Left(5));\n\nlet right: Either<String, u8> = Right(42);\nassert_eq!(right.map_either(f, g), Right(\"42\".into()));Similar to map_either, with an added context ctx accessible to\nboth functions.
use either::*;\n\nlet mut sum = 0;\n\n// Both closures want to update the same value, so pass it as context.\nlet mut f = |sum: &mut usize, s: String| { *sum += s.len(); s.to_uppercase() };\nlet mut g = |sum: &mut usize, u: usize| { *sum += u; u.to_string() };\n\nlet left: Either<String, usize> = Left(\"loopy\".into());\nassert_eq!(left.map_either_with(&mut sum, &mut f, &mut g), Left(\"LOOPY\".into()));\n\nlet right: Either<String, usize> = Right(42);\nassert_eq!(right.map_either_with(&mut sum, &mut f, &mut g), Right(\"42\".into()));\n\nassert_eq!(sum, 47);Apply one of two functions depending on contents, unifying their result. If the value is\nLeft(L) then the first function f is applied; if it is Right(R) then the second\nfunction g is applied.
use either::*;\n\nfn square(n: u32) -> i32 { (n * n) as i32 }\nfn negate(n: i32) -> i32 { -n }\n\nlet left: Either<u32, i32> = Left(4);\nassert_eq!(left.either(square, negate), 16);\n\nlet right: Either<u32, i32> = Right(-4);\nassert_eq!(right.either(square, negate), 4);Like either, but provide some context to whichever of the\nfunctions ends up being called.
// In this example, the context is a mutable reference\nuse either::*;\n\nlet mut result = Vec::new();\n\nlet values = vec![Left(2), Right(2.7)];\n\nfor value in values {\n value.either_with(&mut result,\n |ctx, integer| ctx.push(integer),\n |ctx, real| ctx.push(f64::round(real) as i32));\n}\n\nassert_eq!(result, vec![2, 3]);Apply the function f on the value in the Left variant if it is present.
use either::*;\n\nlet left: Either<_, u32> = Left(123);\nassert_eq!(left.left_and_then::<_,()>(|x| Right(x * 2)), Right(246));\n\nlet right: Either<u32, _> = Right(123);\nassert_eq!(right.left_and_then(|x| Right::<(), _>(x * 2)), Right(123));Apply the function f on the value in the Right variant if it is present.
use either::*;\n\nlet left: Either<_, u32> = Left(123);\nassert_eq!(left.right_and_then(|x| Right(x * 2)), Left(123));\n\nlet right: Either<u32, _> = Right(123);\nassert_eq!(right.right_and_then(|x| Right(x * 2)), Right(246));Convert the inner value to an iterator.
\nThis requires the Left and Right iterators to have the same item type.\nSee factor_into_iter to iterate different types.
use either::*;\n\nlet left: Either<_, Vec<u32>> = Left(vec![1, 2, 3, 4, 5]);\nlet mut right: Either<Vec<u32>, _> = Right(vec![]);\nright.extend(left.into_iter());\nassert_eq!(right, Right(vec![1, 2, 3, 4, 5]));Borrow the inner value as an iterator.
\nThis requires the Left and Right iterators to have the same item type.\nSee factor_iter to iterate different types.
use either::*;\n\nlet left: Either<_, &[u32]> = Left(vec![2, 3]);\nlet mut right: Either<Vec<u32>, _> = Right(&[4, 5][..]);\nlet mut all = vec![1];\nall.extend(left.iter());\nall.extend(right.iter());\nassert_eq!(all, vec![1, 2, 3, 4, 5]);Mutably borrow the inner value as an iterator.
\nThis requires the Left and Right iterators to have the same item type.\nSee factor_iter_mut to iterate different types.
use either::*;\n\nlet mut left: Either<_, &mut [u32]> = Left(vec![2, 3]);\nfor l in left.iter_mut() {\n *l *= *l\n}\nassert_eq!(left, Left(vec![4, 9]));\n\nlet mut inner = [4, 5];\nlet mut right: Either<Vec<u32>, _> = Right(&mut inner[..]);\nfor r in right.iter_mut() {\n *r *= *r\n}\nassert_eq!(inner, [16, 25]);Converts an Either of Iterators to be an Iterator of Eithers
Unlike into_iter, this does not require the\nLeft and Right iterators to have the same item type.
use either::*;\nlet left: Either<_, Vec<u8>> = Left(&[\"hello\"]);\nassert_eq!(left.factor_into_iter().next(), Some(Left(&\"hello\")));\n\nlet right: Either<&[&str], _> = Right(vec![0, 1]);\nassert_eq!(right.factor_into_iter().collect::<Vec<_>>(), vec![Right(0), Right(1)]);\nBorrows an Either of Iterators to be an Iterator of Eithers
Unlike iter, this does not require the\nLeft and Right iterators to have the same item type.
use either::*;\nlet left: Either<_, Vec<u8>> = Left([\"hello\"]);\nassert_eq!(left.factor_iter().next(), Some(Left(&\"hello\")));\n\nlet right: Either<[&str; 2], _> = Right(vec![0, 1]);\nassert_eq!(right.factor_iter().collect::<Vec<_>>(), vec![Right(&0), Right(&1)]);\nMutably borrows an Either of Iterators to be an Iterator of Eithers
Unlike iter_mut, this does not require the\nLeft and Right iterators to have the same item type.
use either::*;\nlet mut left: Either<_, Vec<u8>> = Left([\"hello\"]);\nleft.factor_iter_mut().for_each(|x| *x.unwrap_left() = \"goodbye\");\nassert_eq!(left, Left([\"goodbye\"]));\n\nlet mut right: Either<[&str; 2], _> = Right(vec![0, 1, 2]);\nright.factor_iter_mut().for_each(|x| if let Right(r) = x { *r = -*r; });\nassert_eq!(right, Right(vec![0, -1, -2]));\nReturn left value or given value
\nArguments passed to left_or are eagerly evaluated; if you are passing\nthe result of a function call, it is recommended to use\nleft_or_else, which is lazily evaluated.
let left: Either<&str, &str> = Left(\"left\");\nassert_eq!(left.left_or(\"foo\"), \"left\");\n\nlet right: Either<&str, &str> = Right(\"right\");\nassert_eq!(right.left_or(\"left\"), \"left\");Return left or a default
\nlet left: Either<String, u32> = Left(\"left\".to_string());\nassert_eq!(left.left_or_default(), \"left\");\n\nlet right: Either<String, u32> = Right(42);\nassert_eq!(right.left_or_default(), String::default());Returns left value or computes it from a closure
\nlet left: Either<String, u32> = Left(\"3\".to_string());\nassert_eq!(left.left_or_else(|_| unreachable!()), \"3\");\n\nlet right: Either<String, u32> = Right(3);\nassert_eq!(right.left_or_else(|x| x.to_string()), \"3\");Return right value or given value
\nArguments passed to right_or are eagerly evaluated; if you are passing\nthe result of a function call, it is recommended to use\nright_or_else, which is lazily evaluated.
let right: Either<&str, &str> = Right(\"right\");\nassert_eq!(right.right_or(\"foo\"), \"right\");\n\nlet left: Either<&str, &str> = Left(\"left\");\nassert_eq!(left.right_or(\"right\"), \"right\");Return right or a default
\nlet left: Either<String, u32> = Left(\"left\".to_string());\nassert_eq!(left.right_or_default(), u32::default());\n\nlet right: Either<String, u32> = Right(42);\nassert_eq!(right.right_or_default(), 42);Returns right value or computes it from a closure
\nlet left: Either<String, u32> = Left(\"3\".to_string());\nassert_eq!(left.right_or_else(|x| x.parse().unwrap()), 3);\n\nlet right: Either<String, u32> = Right(3);\nassert_eq!(right.right_or_else(|_| unreachable!()), 3);Convert the contained value into T
// Both u16 and u32 can be converted to u64.\nlet left: Either<u16, u32> = Left(3u16);\nassert_eq!(left.either_into::<u64>(), 3u64);\nlet right: Either<u16, u32> = Right(7u32);\nassert_eq!(right.either_into::<u64>(), 7u64);Extract the value of an either over two equivalent types.
\n\nuse either::*;\n\nlet left: Either<_, u32> = Left(123);\nassert_eq!(left.into_inner(), 123);\n\nlet right: Either<u32, _> = Right(123);\nassert_eq!(right.into_inner(), 123);std only.Either implements Error if both L and R implement it.
Requires crate feature \"std\"
extend_one)extend_one)Convert from Result to Either with Ok => Right and Err => Left.
Either<L, R> is a future if both L and R are futures.
SourceFile). The caller has the responsibility\nto avoid duplicate attributes.(A, B), where the items A are from\nthis iterator and B are from the iterator given as argument.\nLike the zip method on ordinary iterators, if the two\niterators are of unequal length, you only get the items they\nhave in common. Read moreZip, but requires that both iterators have the same length. Read moreParallelIterator with those of\nanother. Read moreParallelIterator with those of\nanother. Read moreParallelIterator\nare equal to those of anotherParallelIterator\nare unequal to those of anotherParallelIterator\nare lexicographically less than those of another.ParallelIterator\nare less than or equal to those of another.ParallelIterator\nare lexicographically greater than those of another.ParallelIterator\nare greater than or equal to those of another.n elements. Read moren elements. Read moreParallelIterator::find_any, the parallel search will not\nnecessarily find the first match, and once a match is\nfound we’ll attempt to stop processing any more. Read morewith_min_len().\nFor example, given min=10 and max=15, a length of 16 will not be\nsplit any further. Read moreEither<L, R> is an iterator if both L and R are iterators.
nth element of the iterator. Read moreiter_next_chunk)N values. Read moreiter_advance_by)n elements. Read moreiter_intersperse)separator between adjacent\nitems of the original iterator. Read moreiter_intersperse)separator\nbetween adjacent items of the original iterator. Read moren elements. Read moren elements, or fewer\nif the underlying iterator ends sooner. Read moreiter_map_windows)f for each contiguous window of size N over\nself and returns an iterator over the outputs of f. Like slice::windows(),\nthe windows during mapping overlap as well. Read moreIterator. Read moreiterator_try_collect)iter_collect_into)iter_partition_in_place)true precede all those that return false.\nReturns the number of true elements found. Read moreiter_is_partitioned)true precede all those that return false. Read moreiterator_try_reduce)try_find)iter_array_chunks)N elements of the iterator at a time. Read moreiter_order_by)Iterator with those\nof another with respect to the specified comparison function. Read morePartialOrd elements of\nthis Iterator with those of another. The comparison works like short-circuit\nevaluation, returning a result without comparing the remaining elements.\nAs soon as an order can be determined, the evaluation stops and a result is returned. Read moreiter_order_by)Iterator with those\nof another with respect to the specified comparison function. Read moreiter_order_by)Iterator are lexicographically\nless than those of another. Read moreIterator are lexicographically\nless or equal to those of another. Read moreIterator are lexicographically\ngreater than those of another. Read moreIterator are lexicographically\ngreater than or equal to those of another. Read moreEither<L, R> can be extended if both L and R are parallel extendable.
par_iter. Read moreEither<L, R> is a parallel iterator if both L and R are parallel iterators.
for_each method, this is the type of\nitem that your closure will be invoked with.OP on each item produced by the iterator, in parallel. Read moreOP on the given init value with each item produced by\nthe iterator, in parallel. Read moreOP on a value returned by init with each item produced by\nthe iterator, in parallel. Read moreOP on each item produced by the iterator, in parallel. Read moreOP on the given init value with each item\nproduced by the iterator, in parallel. Read moreOP on a value returned by init with each item\nproduced by the iterator, in parallel. Read moremap_op to each item of this iterator, producing a new\niterator with the results. Read moremap_op to the given init value with each item of this\niterator, producing a new iterator with the results. Read moremap_op to a value returned by init with each item of this\niterator, producing a new iterator with the results. Read moreinspect_op to a reference to each item of this iterator,\nproducing a new iterator passing through the original items. This is\noften useful for debugging to see what’s happening in iterator stages. Read morefilter_op to each item of this iterator, producing a new\niterator with only the items that gave true results. Read morefilter_op to each item of this iterator to get an Option,\nproducing a new iterator with only the items from Some results. Read moremap_op to each item of this iterator to get nested parallel iterators,\nproducing a new parallel iterator that flattens these back into one. Read moremap_op to each item of this iterator to get nested serial iterators,\nproducing a new parallel iterator that flattens these back into one. Read moreItems into one large iterator. Read moreItems into one large iterator. Read moreop.\nThe argument identity should be a closure that can produce\n“identity” value which may be inserted into the sequence as\nneeded to create opportunities for parallel execution. So, for\nexample, if you are doing a summation, then identity() ought\nto produce something that represents the zero for your type\n(but consider just calling sum() in that case). Read moreop.\nIf the iterator is empty, None is returned; otherwise,\nSome is returned. Read moreop. Read more22 3 77 89 46. If\nyou used sequential fold to add them (fold(0, |a,b| a+b),\nyou would wind up first adding 0 + 22, then 22 + 3, then 25 +\n77, and so forth. The parallel fold works similarly except\nthat it first breaks up your list into sublists, and hence\ninstead of yielding up a single sum at the end, it yields up\nmultiple sums. The number of results is nondeterministic, as\nis the point where the breaks occur. Read morefold_op to the given init value with each item of this\niterator, finally producing the value for further use. Read moreinit value. Read moreNone is returned; otherwise, Some(min)\nis returned. Read moreNone is\nreturned; otherwise, Some(min) is returned. Read moreNone is returned;\notherwise, Some(item) is returned. Read moreNone is returned; otherwise, Some(max)\nis returned. Read moreNone is\nreturned; otherwise, Some(max) is returned. Read moreNone is returned;\notherwise, Some(item) is returned. Read morefind on sequential iterators but\nthe item returned may not be the first one in the parallel\nsequence which matches, since we search the entire sequence in parallel. Read moreSome items of this iterator, halting\nas soon as any None is found. Read moreParallelExtend containers. Read moreParallelExtend containers. Items for which the predicate returns\ntrue go into the first container, and the rest go into the second. Read moreParallelExtend containers. Either::Left items go into\nthe first container, and Either::Right items go into the second. Read moren elements from anywhere in the original iterator. Read moren elements from anywhere in the original iterator. Read morepredicate returns false. Read morepredicate returns false. Read morestd only.Either<L, R> implements Read if both L and R do.
Requires crate feature \"std\"
buf. Read morebuf. Read morebuf. Read moreread, except that it reads into a slice of buffers. Read morecan_vector)read_buf)read_buf)cursor. Read moreRead. Read morestd only.Either<L, R> implements Seek if both L and R do.
Requires crate feature \"std\"
seek_stream_len)rayon only.std only.Either<L, R> implements Write if both L and R do.
Requires crate feature \"std\"
can_vector)std only.Requires crate feature std.
std only.Requires crate feature std.
std only.Requires crate feature std.
std only.Requires crate feature std.
std only.Requires crate feature std.
std only.Requires crate feature std.
std only.Requires crate feature \"std\"
Read methods, if empty. Read moreamount of additional bytes from the internal buffer as having been read.\nSubsequent calls to read only return bytes that have not been marked as read. Read more0xA byte) is reached, and append\nthem to the provided String buffer. Read morebuf_read_has_data_left)read. Read morebyte or EOF is reached. Read morenth element from the end of the iterator. Read moreReturn true if the value is the Left variant.
use either::*;\n\nlet values = [Left(1), Right(\"the right value\")];\nassert_eq!(values[0].is_left(), true);\nassert_eq!(values[1].is_left(), false);Return true if the value is the Right variant.
use either::*;\n\nlet values = [Left(1), Right(\"the right value\")];\nassert_eq!(values[0].is_right(), false);\nassert_eq!(values[1].is_right(), true);Convert the left side of Either<L, R> to an Option<L>.
use either::*;\n\nlet left: Either<_, ()> = Left(\"some value\");\nassert_eq!(left.left(), Some(\"some value\"));\n\nlet right: Either<(), _> = Right(321);\nassert_eq!(right.left(), None);Convert the right side of Either<L, R> to an Option<R>.
use either::*;\n\nlet left: Either<_, ()> = Left(\"some value\");\nassert_eq!(left.right(), None);\n\nlet right: Either<(), _> = Right(321);\nassert_eq!(right.right(), Some(321));Convert &Either<L, R> to Either<&L, &R>.
use either::*;\n\nlet left: Either<_, ()> = Left(\"some value\");\nassert_eq!(left.as_ref(), Left(&\"some value\"));\n\nlet right: Either<(), _> = Right(\"some value\");\nassert_eq!(right.as_ref(), Right(&\"some value\"));Convert &mut Either<L, R> to Either<&mut L, &mut R>.
use either::*;\n\nfn mutate_left(value: &mut Either<u32, u32>) {\n if let Some(l) = value.as_mut().left() {\n *l = 999;\n }\n}\n\nlet mut left = Left(123);\nlet mut right = Right(123);\nmutate_left(&mut left);\nmutate_left(&mut right);\nassert_eq!(left, Left(999));\nassert_eq!(right, Right(123));Convert Pin<&Either<L, R>> to Either<Pin<&L>, Pin<&R>>,\npinned projections of the inner variants.
Convert Pin<&mut Either<L, R>> to Either<Pin<&mut L>, Pin<&mut R>>,\npinned projections of the inner variants.
Convert Either<L, R> to Either<R, L>.
use either::*;\n\nlet left: Either<_, ()> = Left(123);\nassert_eq!(left.flip(), Right(123));\n\nlet right: Either<(), _> = Right(\"some value\");\nassert_eq!(right.flip(), Left(\"some value\"));Apply the function f on the value in the Left variant if it is present rewrapping the\nresult in Left.
use either::*;\n\nlet left: Either<_, u32> = Left(123);\nassert_eq!(left.map_left(|x| x * 2), Left(246));\n\nlet right: Either<u32, _> = Right(123);\nassert_eq!(right.map_left(|x| x * 2), Right(123));Apply the function f on the value in the Right variant if it is present rewrapping the\nresult in Right.
use either::*;\n\nlet left: Either<_, u32> = Left(123);\nassert_eq!(left.map_right(|x| x * 2), Left(123));\n\nlet right: Either<u32, _> = Right(123);\nassert_eq!(right.map_right(|x| x * 2), Right(246));Apply the functions f and g to the Left and Right variants\nrespectively. This is equivalent to\nbimap\nin functional programming.
use either::*;\n\nlet f = |s: String| s.len();\nlet g = |u: u8| u.to_string();\n\nlet left: Either<String, u8> = Left(\"loopy\".into());\nassert_eq!(left.map_either(f, g), Left(5));\n\nlet right: Either<String, u8> = Right(42);\nassert_eq!(right.map_either(f, g), Right(\"42\".into()));Similar to map_either, with an added context ctx accessible to\nboth functions.
use either::*;\n\nlet mut sum = 0;\n\n// Both closures want to update the same value, so pass it as context.\nlet mut f = |sum: &mut usize, s: String| { *sum += s.len(); s.to_uppercase() };\nlet mut g = |sum: &mut usize, u: usize| { *sum += u; u.to_string() };\n\nlet left: Either<String, usize> = Left(\"loopy\".into());\nassert_eq!(left.map_either_with(&mut sum, &mut f, &mut g), Left(\"LOOPY\".into()));\n\nlet right: Either<String, usize> = Right(42);\nassert_eq!(right.map_either_with(&mut sum, &mut f, &mut g), Right(\"42\".into()));\n\nassert_eq!(sum, 47);Apply one of two functions depending on contents, unifying their result. If the value is\nLeft(L) then the first function f is applied; if it is Right(R) then the second\nfunction g is applied.
use either::*;\n\nfn square(n: u32) -> i32 { (n * n) as i32 }\nfn negate(n: i32) -> i32 { -n }\n\nlet left: Either<u32, i32> = Left(4);\nassert_eq!(left.either(square, negate), 16);\n\nlet right: Either<u32, i32> = Right(-4);\nassert_eq!(right.either(square, negate), 4);Like either, but provide some context to whichever of the\nfunctions ends up being called.
// In this example, the context is a mutable reference\nuse either::*;\n\nlet mut result = Vec::new();\n\nlet values = vec![Left(2), Right(2.7)];\n\nfor value in values {\n value.either_with(&mut result,\n |ctx, integer| ctx.push(integer),\n |ctx, real| ctx.push(f64::round(real) as i32));\n}\n\nassert_eq!(result, vec![2, 3]);Apply the function f on the value in the Left variant if it is present.
use either::*;\n\nlet left: Either<_, u32> = Left(123);\nassert_eq!(left.left_and_then::<_,()>(|x| Right(x * 2)), Right(246));\n\nlet right: Either<u32, _> = Right(123);\nassert_eq!(right.left_and_then(|x| Right::<(), _>(x * 2)), Right(123));Apply the function f on the value in the Right variant if it is present.
use either::*;\n\nlet left: Either<_, u32> = Left(123);\nassert_eq!(left.right_and_then(|x| Right(x * 2)), Left(123));\n\nlet right: Either<u32, _> = Right(123);\nassert_eq!(right.right_and_then(|x| Right(x * 2)), Right(246));Convert the inner value to an iterator.
\nThis requires the Left and Right iterators to have the same item type.\nSee factor_into_iter to iterate different types.
use either::*;\n\nlet left: Either<_, Vec<u32>> = Left(vec![1, 2, 3, 4, 5]);\nlet mut right: Either<Vec<u32>, _> = Right(vec![]);\nright.extend(left.into_iter());\nassert_eq!(right, Right(vec![1, 2, 3, 4, 5]));Borrow the inner value as an iterator.
\nThis requires the Left and Right iterators to have the same item type.\nSee factor_iter to iterate different types.
use either::*;\n\nlet left: Either<_, &[u32]> = Left(vec![2, 3]);\nlet mut right: Either<Vec<u32>, _> = Right(&[4, 5][..]);\nlet mut all = vec![1];\nall.extend(left.iter());\nall.extend(right.iter());\nassert_eq!(all, vec![1, 2, 3, 4, 5]);Mutably borrow the inner value as an iterator.
\nThis requires the Left and Right iterators to have the same item type.\nSee factor_iter_mut to iterate different types.
use either::*;\n\nlet mut left: Either<_, &mut [u32]> = Left(vec![2, 3]);\nfor l in left.iter_mut() {\n *l *= *l\n}\nassert_eq!(left, Left(vec![4, 9]));\n\nlet mut inner = [4, 5];\nlet mut right: Either<Vec<u32>, _> = Right(&mut inner[..]);\nfor r in right.iter_mut() {\n *r *= *r\n}\nassert_eq!(inner, [16, 25]);Converts an Either of Iterators to be an Iterator of Eithers
Unlike into_iter, this does not require the\nLeft and Right iterators to have the same item type.
use either::*;\nlet left: Either<_, Vec<u8>> = Left(&[\"hello\"]);\nassert_eq!(left.factor_into_iter().next(), Some(Left(&\"hello\")));\n\nlet right: Either<&[&str], _> = Right(vec![0, 1]);\nassert_eq!(right.factor_into_iter().collect::<Vec<_>>(), vec![Right(0), Right(1)]);\nBorrows an Either of Iterators to be an Iterator of Eithers
Unlike iter, this does not require the\nLeft and Right iterators to have the same item type.
use either::*;\nlet left: Either<_, Vec<u8>> = Left([\"hello\"]);\nassert_eq!(left.factor_iter().next(), Some(Left(&\"hello\")));\n\nlet right: Either<[&str; 2], _> = Right(vec![0, 1]);\nassert_eq!(right.factor_iter().collect::<Vec<_>>(), vec![Right(&0), Right(&1)]);\nMutably borrows an Either of Iterators to be an Iterator of Eithers
Unlike iter_mut, this does not require the\nLeft and Right iterators to have the same item type.
use either::*;\nlet mut left: Either<_, Vec<u8>> = Left([\"hello\"]);\nleft.factor_iter_mut().for_each(|x| *x.unwrap_left() = \"goodbye\");\nassert_eq!(left, Left([\"goodbye\"]));\n\nlet mut right: Either<[&str; 2], _> = Right(vec![0, 1, 2]);\nright.factor_iter_mut().for_each(|x| if let Right(r) = x { *r = -*r; });\nassert_eq!(right, Right(vec![0, -1, -2]));\nReturn left value or given value
\nArguments passed to left_or are eagerly evaluated; if you are passing\nthe result of a function call, it is recommended to use\nleft_or_else, which is lazily evaluated.
let left: Either<&str, &str> = Left(\"left\");\nassert_eq!(left.left_or(\"foo\"), \"left\");\n\nlet right: Either<&str, &str> = Right(\"right\");\nassert_eq!(right.left_or(\"left\"), \"left\");Return left or a default
\nlet left: Either<String, u32> = Left(\"left\".to_string());\nassert_eq!(left.left_or_default(), \"left\");\n\nlet right: Either<String, u32> = Right(42);\nassert_eq!(right.left_or_default(), String::default());Returns left value or computes it from a closure
\nlet left: Either<String, u32> = Left(\"3\".to_string());\nassert_eq!(left.left_or_else(|_| unreachable!()), \"3\");\n\nlet right: Either<String, u32> = Right(3);\nassert_eq!(right.left_or_else(|x| x.to_string()), \"3\");Return right value or given value
\nArguments passed to right_or are eagerly evaluated; if you are passing\nthe result of a function call, it is recommended to use\nright_or_else, which is lazily evaluated.
let right: Either<&str, &str> = Right(\"right\");\nassert_eq!(right.right_or(\"foo\"), \"right\");\n\nlet left: Either<&str, &str> = Left(\"left\");\nassert_eq!(left.right_or(\"right\"), \"right\");Return right or a default
\nlet left: Either<String, u32> = Left(\"left\".to_string());\nassert_eq!(left.right_or_default(), u32::default());\n\nlet right: Either<String, u32> = Right(42);\nassert_eq!(right.right_or_default(), 42);Returns right value or computes it from a closure
\nlet left: Either<String, u32> = Left(\"3\".to_string());\nassert_eq!(left.right_or_else(|x| x.parse().unwrap()), 3);\n\nlet right: Either<String, u32> = Right(3);\nassert_eq!(right.right_or_else(|_| unreachable!()), 3);Convert the contained value into T
// Both u16 and u32 can be converted to u64.\nlet left: Either<u16, u32> = Left(3u16);\nassert_eq!(left.either_into::<u64>(), 3u64);\nlet right: Either<u16, u32> = Right(7u32);\nassert_eq!(right.either_into::<u64>(), 7u64);Extract the value of an either over two equivalent types.
\n\nuse either::*;\n\nlet left: Either<_, u32> = Left(123);\nassert_eq!(left.into_inner(), 123);\n\nlet right: Either<u32, _> = Right(123);\nassert_eq!(right.into_inner(), 123);std only.Either implements Error if both L and R implement it.
Requires crate feature \"std\"
extend_one)extend_one)Convert from Result to Either with Ok => Right and Err => Left.
Either<L, R> is a future if both L and R are futures.
SourceFile). The caller has the responsibility\nto avoid duplicate attributes.(A, B), where the items A are from\nthis iterator and B are from the iterator given as argument.\nLike the zip method on ordinary iterators, if the two\niterators are of unequal length, you only get the items they\nhave in common. Read moreZip, but requires that both iterators have the same length. Read moreParallelIterator with those of\nanother. Read moreParallelIterator with those of\nanother. Read moreParallelIterator\nare equal to those of anotherParallelIterator\nare unequal to those of anotherParallelIterator\nare lexicographically less than those of another.ParallelIterator\nare less than or equal to those of another.ParallelIterator\nare lexicographically greater than those of another.ParallelIterator\nare greater than or equal to those of another.n elements. Read moren elements. Read moreParallelIterator::find_any, the parallel search will not\nnecessarily find the first match, and once a match is\nfound we’ll attempt to stop processing any more. Read morewith_min_len().\nFor example, given min=10 and max=15, a length of 16 will not be\nsplit any further. Read moreEither<L, R> is an iterator if both L and R are iterators.
nth element of the iterator. Read moreiter_next_chunk)N values. Read moreiter_advance_by)n elements. Read moreiter_intersperse)separator between adjacent\nitems of the original iterator. Read moreiter_intersperse)separator\nbetween adjacent items of the original iterator. Read moren elements. Read moren elements, or fewer\nif the underlying iterator ends sooner. Read moreiter_map_windows)f for each contiguous window of size N over\nself and returns an iterator over the outputs of f. Like slice::windows(),\nthe windows during mapping overlap as well. Read moreIterator. Read moreiterator_try_collect)iter_collect_into)iter_partition_in_place)true precede all those that return false.\nReturns the number of true elements found. Read moreiter_is_partitioned)true precede all those that return false. Read moreiterator_try_reduce)try_find)iter_array_chunks)N elements of the iterator at a time. Read moreiter_order_by)Iterator with those\nof another with respect to the specified comparison function. Read morePartialOrd elements of\nthis Iterator with those of another. The comparison works like short-circuit\nevaluation, returning a result without comparing the remaining elements.\nAs soon as an order can be determined, the evaluation stops and a result is returned. Read moreiter_order_by)Iterator with those\nof another with respect to the specified comparison function. Read moreiter_order_by)Iterator are lexicographically\nless than those of another. Read moreIterator are lexicographically\nless or equal to those of another. Read moreIterator are lexicographically\ngreater than those of another. Read moreIterator are lexicographically\ngreater than or equal to those of another. Read moreEither<L, R> can be extended if both L and R are parallel extendable.
par_iter. Read moreEither<L, R> is a parallel iterator if both L and R are parallel iterators.
for_each method, this is the type of\nitem that your closure will be invoked with.OP on each item produced by the iterator, in parallel. Read moreOP on the given init value with each item produced by\nthe iterator, in parallel. Read moreOP on a value returned by init with each item produced by\nthe iterator, in parallel. Read moreOP on each item produced by the iterator, in parallel. Read moreOP on the given init value with each item\nproduced by the iterator, in parallel. Read moreOP on a value returned by init with each item\nproduced by the iterator, in parallel. Read moremap_op to each item of this iterator, producing a new\niterator with the results. Read moremap_op to the given init value with each item of this\niterator, producing a new iterator with the results. Read moremap_op to a value returned by init with each item of this\niterator, producing a new iterator with the results. Read moreinspect_op to a reference to each item of this iterator,\nproducing a new iterator passing through the original items. This is\noften useful for debugging to see what’s happening in iterator stages. Read morefilter_op to each item of this iterator, producing a new\niterator with only the items that gave true results. Read morefilter_op to each item of this iterator to get an Option,\nproducing a new iterator with only the items from Some results. Read moremap_op to each item of this iterator to get nested parallel iterators,\nproducing a new parallel iterator that flattens these back into one. Read moremap_op to each item of this iterator to get nested serial iterators,\nproducing a new parallel iterator that flattens these back into one. Read moreItems into one large iterator. Read moreItems into one large iterator. Read moreop.\nThe argument identity should be a closure that can produce\n“identity” value which may be inserted into the sequence as\nneeded to create opportunities for parallel execution. So, for\nexample, if you are doing a summation, then identity() ought\nto produce something that represents the zero for your type\n(but consider just calling sum() in that case). Read moreop.\nIf the iterator is empty, None is returned; otherwise,\nSome is returned. Read moreop. Read more22 3 77 89 46. If\nyou used sequential fold to add them (fold(0, |a,b| a+b),\nyou would wind up first adding 0 + 22, then 22 + 3, then 25 +\n77, and so forth. The parallel fold works similarly except\nthat it first breaks up your list into sublists, and hence\ninstead of yielding up a single sum at the end, it yields up\nmultiple sums. The number of results is nondeterministic, as\nis the point where the breaks occur. Read morefold_op to the given init value with each item of this\niterator, finally producing the value for further use. Read moreinit value. Read moreNone is returned; otherwise, Some(min)\nis returned. Read moreNone is\nreturned; otherwise, Some(min) is returned. Read moreNone is returned;\notherwise, Some(item) is returned. Read moreNone is returned; otherwise, Some(max)\nis returned. Read moreNone is\nreturned; otherwise, Some(max) is returned. Read moreNone is returned;\notherwise, Some(item) is returned. Read morefind on sequential iterators but\nthe item returned may not be the first one in the parallel\nsequence which matches, since we search the entire sequence in parallel. Read moreSome items of this iterator, halting\nas soon as any None is found. Read moreParallelExtend containers. Read moreParallelExtend containers. Items for which the predicate returns\ntrue go into the first container, and the rest go into the second. Read moreParallelExtend containers. Either::Left items go into\nthe first container, and Either::Right items go into the second. Read moren elements from anywhere in the original iterator. Read moren elements from anywhere in the original iterator. Read morepredicate returns false. Read morepredicate returns false. Read morestd only.Either<L, R> implements Read if both L and R do.
Requires crate feature \"std\"
buf. Read morebuf. Read morebuf. Read moreread, except that it reads into a slice of buffers. Read morecan_vector)read_buf)read_buf)cursor. Read moreRead. Read morestd only.Either<L, R> implements Seek if both L and R do.
Requires crate feature \"std\"
seek_stream_len)rayon only.std only.Either<L, R> implements Write if both L and R do.
Requires crate feature \"std\"
can_vector)