Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
coolreader18 committed Feb 7, 2024
1 parent b5a9a0e commit 3805762
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1962,6 +1962,9 @@ pub trait ParallelIterator: Sized + Send {
/// of how many elements the iterator contains, and even allows you to reuse
/// an existing vector's backing store rather than allocating a fresh vector.
///
/// See also [`collect_vec_list()`][Self::collect_vec_list] for collecting
/// into a `LinkedList<Vec<T>>`.
///
/// [`IndexedParallelIterator`]: trait.IndexedParallelIterator.html
/// [`collect_into_vec()`]:
/// trait.IndexedParallelIterator.html#method.collect_into_vec
Expand Down Expand Up @@ -2367,7 +2370,9 @@ pub trait ParallelIterator: Sized + Send {
/// .flat_map(|x| 0..x)
/// .collect_vec_list();
///
/// let total_len = result.iter().flatten().count();
/// // `par_iter.collect_vec_list().into_iter().flatten()` turns
/// // a parallel iterator into a serial one
/// let total_len = result.into_iter().flatten().count();
/// assert_eq!(total_len, 2550);
/// ```
fn collect_vec_list(self) -> LinkedList<Vec<Self::Item>> {
Expand Down Expand Up @@ -3232,14 +3237,15 @@ where
///
/// If your collection is not naturally parallel, the easiest (and
/// fastest) way to do this is often to collect `par_iter` into a
/// [`LinkedList`] or other intermediate data structure and then
/// sequentially extend your collection. However, a more 'native'
/// technique is to use the [`par_iter.fold`] or
/// [`LinkedList`] (via [`collect_vec_list`]) or another intermediate
/// data structure and then sequentially extend your collection. However,
/// a more 'native' technique is to use the [`par_iter.fold`] or
/// [`par_iter.fold_with`] methods to create the collection.
/// Alternatively, if your collection is 'natively' parallel, you
/// can use `par_iter.for_each` to process each element in turn.
///
/// [`LinkedList`]: https://doc.rust-lang.org/std/collections/struct.LinkedList.html
/// [`collect_vec_list`]: ParallelIterator::collect_vec_list
/// [`par_iter.fold`]: trait.ParallelIterator.html#method.fold
/// [`par_iter.fold_with`]: trait.ParallelIterator.html#method.fold_with
/// [`par_iter.for_each`]: trait.ParallelIterator.html#method.for_each
Expand Down

0 comments on commit 3805762

Please sign in to comment.