diff --git a/src/iter/extend.rs b/src/iter/extend.rs index 1769d476b..a2645280f 100644 --- a/src/iter/extend.rs +++ b/src/iter/extend.rs @@ -500,6 +500,16 @@ impl ParallelExtend for String { } } +/// Extends a string with boxed strings from a parallel iterator. +impl ParallelExtend> for String { + fn par_extend(&mut self, par_iter: I) + where + I: IntoParallelIterator>, + { + extend!(self, par_iter, string_extend); + } +} + /// Extends a string with string slices from a parallel iterator. impl<'a> ParallelExtend> for String { fn par_extend(&mut self, par_iter: I) diff --git a/src/iter/from_par_iter.rs b/src/iter/from_par_iter.rs index 3240f32e2..49afd6cb8 100644 --- a/src/iter/from_par_iter.rs +++ b/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(par_iter: I) -> C @@ -31,6 +33,45 @@ where } } +/// Collects items from a parallel iterator into a boxed slice. +impl FromParallelIterator for Box<[T]> +where + T: Send, +{ + fn from_par_iter(par_iter: I) -> Self + where + I: IntoParallelIterator, + { + Vec::from_par_iter(par_iter).into() + } +} + +/// Collects items from a parallel iterator into a reference-counted slice. +impl FromParallelIterator for Rc<[T]> +where + T: Send, +{ + fn from_par_iter(par_iter: I) -> Self + where + I: IntoParallelIterator, + { + Vec::from_par_iter(par_iter).into() + } +} + +/// Collects items from a parallel iterator into an atomically-reference-counted slice. +impl FromParallelIterator for Arc<[T]> +where + T: Send, +{ + fn from_par_iter(par_iter: I) -> Self + where + I: IntoParallelIterator, + { + Vec::from_par_iter(par_iter).into() + } +} + /// Collects items from a parallel iterator into a vecdeque. impl FromParallelIterator for VecDeque where @@ -174,6 +215,16 @@ impl FromParallelIterator for String { } } +/// Collects boxed strings from a parallel iterator into one large string. +impl FromParallelIterator> for String { + fn from_par_iter(par_iter: I) -> Self + where + I: IntoParallelIterator>, + { + collect_extended(par_iter) + } +} + /// Collects string slices from a parallel iterator into a string. impl<'a> FromParallelIterator> for String { fn from_par_iter(par_iter: I) -> Self