# [−][src]Trait rayon::prelude::ParallelBridge

    pub trait ParallelBridge: Sized {
        fn par_bridge(self) -> IterBridge<Self>;
    }

Conversion trait to convert an `Iterator` to a `ParallelIterator`.

This creates a "bridge" from a sequential iterator to a parallel one, by distributing its items across the Rayon thread pool. This has the advantage of being able to parallelize just about anything, but the resulting `ParallelIterator` can be less efficient than if you started with `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.

The resulting iterator is not guaranteed to keep the order of the original iterator.

# Examples

To use this trait, take an existing `Iterator` and call `par_bridge` on it. After that, you can use any of the `ParallelIterator` methods:

    use rayon::iter::ParallelBridge;
    use rayon::prelude::ParallelIterator;
    use std::sync::mpsc::channel;

    let rx = {
        let (tx, rx) = channel();

        tx.send("one!");
        tx.send("two!");
        tx.send("three!");

        rx
    };

    let mut output: Vec<&'static str> = rx.into_iter().par_bridge().collect();
    output.sort_unstable();

    assert_eq!(&*output, &["one!", "three!", "two!"]);

## Required methods

### `fn par_bridge(self) -> IterBridge<Self>`

Create a bridge from this type to a `ParallelIterator`.

Loading content...

## Implementors

### `impl<T: Iterator + Send> ParallelBridge for T where
T::Item: Send,` [src]

#### `fn par_bridge(self) -> IterBridge<Self>`[src]

Loading content...

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)