Trait ParIntoCopied

Source
pub trait ParIntoCopied<'a, T>: Par<Item = &'a T>
where T: Send + Sync + Copy + 'a,
{ // Provided method fn copied(self) -> impl Par<Item = T> { ... } }
Expand description

Transforms a parallel iterator yielding &T into one that yields T by copying each element.

Transformation is via the copied method.

§Examples

use orx_parallel::*;

let numbers = vec![1, 2, 3, 4];

let sum = numbers.par().copied().sum();
let product = numbers.par().copied().fold(|| 1, |x, y| x * y);

assert_eq!(sum, 10);
assert_eq!(product, 24);

Provided Methods§

Source

fn copied(self) -> impl Par<Item = T>

Transforms a parallel iterator yielding &T into one that yields T by copying each element.

Transformation is via the copied method.

§Examples
use orx_parallel::*;

let numbers = vec![1, 2, 3, 4];

let sum = numbers.par().copied().sum();
let product = numbers.par().copied().fold(|| 1, |x, y| x * y);

assert_eq!(sum, 10);
assert_eq!(product, 24);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, T, P> ParIntoCopied<'a, T> for P
where T: Send + Sync + Copy + 'a, P: Par<Item = &'a T>,