diff options
Diffstat (limited to 'vendor/rayon/src/iter')
-rw-r--r-- | vendor/rayon/src/iter/extend.rs | 10 | ||||
-rw-r--r-- | vendor/rayon/src/iter/from_par_iter.rs | 51 | ||||
-rw-r--r-- | vendor/rayon/src/iter/mod.rs | 10 | ||||
-rw-r--r-- | vendor/rayon/src/iter/par_bridge.rs | 5 | ||||
-rw-r--r-- | vendor/rayon/src/iter/product.rs | 2 | ||||
-rw-r--r-- | vendor/rayon/src/iter/sum.rs | 2 |
6 files changed, 73 insertions, 7 deletions
diff --git a/vendor/rayon/src/iter/extend.rs b/vendor/rayon/src/iter/extend.rs index 1769d476b..a2645280f 100644 --- a/vendor/rayon/src/iter/extend.rs +++ b/vendor/rayon/src/iter/extend.rs @@ -500,6 +500,16 @@ impl ParallelExtend<String> for String { } } +/// Extends a string with boxed strings from a parallel iterator. +impl ParallelExtend<Box<str>> for String { + fn par_extend<I>(&mut self, par_iter: I) + where + I: IntoParallelIterator<Item = Box<str>>, + { + extend!(self, par_iter, string_extend); + } +} + /// Extends a string with string slices from a parallel iterator. impl<'a> ParallelExtend<Cow<'a, str>> for String { fn par_extend<I>(&mut self, par_iter: I) diff --git a/vendor/rayon/src/iter/from_par_iter.rs b/vendor/rayon/src/iter/from_par_iter.rs index 3240f32e2..49afd6cb8 100644 --- a/vendor/rayon/src/iter/from_par_iter.rs +++ b/vendor/rayon/src/iter/from_par_iter.rs @@ -6,6 +6,8 @@ use std::collections::LinkedList; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::collections::{BinaryHeap, VecDeque}; use std::hash::{BuildHasher, Hash}; +use std::rc::Rc; +use std::sync::Arc; /// Creates an empty default collection and extends it. fn collect_extended<C, I>(par_iter: I) -> C @@ -31,6 +33,45 @@ where } } +/// Collects items from a parallel iterator into a boxed slice. +impl<T> FromParallelIterator<T> for Box<[T]> +where + T: Send, +{ + fn from_par_iter<I>(par_iter: I) -> Self + where + I: IntoParallelIterator<Item = T>, + { + Vec::from_par_iter(par_iter).into() + } +} + +/// Collects items from a parallel iterator into a reference-counted slice. +impl<T> FromParallelIterator<T> for Rc<[T]> +where + T: Send, +{ + fn from_par_iter<I>(par_iter: I) -> Self + where + I: IntoParallelIterator<Item = T>, + { + Vec::from_par_iter(par_iter).into() + } +} + +/// Collects items from a parallel iterator into an atomically-reference-counted slice. +impl<T> FromParallelIterator<T> for Arc<[T]> +where + T: Send, +{ + fn from_par_iter<I>(par_iter: I) -> Self + where + I: IntoParallelIterator<Item = T>, + { + Vec::from_par_iter(par_iter).into() + } +} + /// Collects items from a parallel iterator into a vecdeque. impl<T> FromParallelIterator<T> for VecDeque<T> where @@ -174,6 +215,16 @@ impl FromParallelIterator<String> for String { } } +/// Collects boxed strings from a parallel iterator into one large string. +impl FromParallelIterator<Box<str>> for String { + fn from_par_iter<I>(par_iter: I) -> Self + where + I: IntoParallelIterator<Item = Box<str>>, + { + collect_extended(par_iter) + } +} + /// Collects string slices from a parallel iterator into a string. impl<'a> FromParallelIterator<Cow<'a, str>> for String { fn from_par_iter<I>(par_iter: I) -> Self diff --git a/vendor/rayon/src/iter/mod.rs b/vendor/rayon/src/iter/mod.rs index e60ea1633..7b5a29aeb 100644 --- a/vendor/rayon/src/iter/mod.rs +++ b/vendor/rayon/src/iter/mod.rs @@ -1547,7 +1547,7 @@ pub trait ParallelIterator: Sized + Send { /// Computes the maximum of all the items in the iterator with respect to /// the given comparison function. If the iterator is empty, `None` is - /// returned; otherwise, `Some(min)` is returned. + /// returned; otherwise, `Some(max)` is returned. /// /// Note that the order in which the items will be reduced is not /// specified, so if the comparison function is not associative, then @@ -2392,7 +2392,7 @@ impl<T: ParallelIterator> IntoParallelIterator for T { #[allow(clippy::len_without_is_empty)] pub trait IndexedParallelIterator: ParallelIterator { /// Collects the results of the iterator into the specified - /// vector. The vector is always truncated before execution + /// vector. The vector is always cleared before execution /// begins. If possible, reusing the vector across calls can lead /// to better performance since it reuses the same backing buffer. /// @@ -2401,7 +2401,7 @@ pub trait IndexedParallelIterator: ParallelIterator { /// ``` /// use rayon::prelude::*; /// - /// // any prior data will be truncated + /// // any prior data will be cleared /// let mut vec = vec![-1, -2, -3]; /// /// (0..5).into_par_iter() @@ -2414,7 +2414,7 @@ pub trait IndexedParallelIterator: ParallelIterator { } /// Unzips the results of the iterator into the specified - /// vectors. The vectors are always truncated before execution + /// vectors. The vectors are always cleared before execution /// begins. If possible, reusing the vectors across calls can lead /// to better performance since they reuse the same backing buffer. /// @@ -2423,7 +2423,7 @@ pub trait IndexedParallelIterator: ParallelIterator { /// ``` /// use rayon::prelude::*; /// - /// // any prior data will be truncated + /// // any prior data will be cleared /// let mut left = vec![42; 10]; /// let mut right = vec![-1; 10]; /// diff --git a/vendor/rayon/src/iter/par_bridge.rs b/vendor/rayon/src/iter/par_bridge.rs index 8398274b3..eb058d3e6 100644 --- a/vendor/rayon/src/iter/par_bridge.rs +++ b/vendor/rayon/src/iter/par_bridge.rs @@ -13,6 +13,11 @@ use crate::{current_num_threads, current_thread_index}; /// `par_iter` instead. However, it can still be useful for iterators that are difficult to /// parallelize by other means, like channels or file or network I/O. /// +/// Iterator items are pulled by `next()` one at a time, synchronized from each thread that is +/// ready for work, so this may become a bottleneck if the serial iterator can't keep up with the +/// parallel demand. The items are not buffered by `IterBridge`, so it's fine to use this with +/// large or even unbounded iterators. +/// /// The resulting iterator is not guaranteed to keep the order of the original iterator. /// /// # Examples diff --git a/vendor/rayon/src/iter/product.rs b/vendor/rayon/src/iter/product.rs index a3d0727f9..e081be06b 100644 --- a/vendor/rayon/src/iter/product.rs +++ b/vendor/rayon/src/iter/product.rs @@ -13,7 +13,7 @@ where } fn mul<T: Product>(left: T, right: T) -> T { - iter::once(left).chain(iter::once(right)).product() + [left, right].into_iter().product() } struct ProductConsumer<P: Send> { diff --git a/vendor/rayon/src/iter/sum.rs b/vendor/rayon/src/iter/sum.rs index a73e0bf3d..ddae810f9 100644 --- a/vendor/rayon/src/iter/sum.rs +++ b/vendor/rayon/src/iter/sum.rs @@ -13,7 +13,7 @@ where } fn add<T: Sum>(left: T, right: T) -> T { - iter::once(left).chain(iter::once(right)).sum() + [left, right].into_iter().sum() } struct SumConsumer<S: Send> { |