Trait ParIntoCloned

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

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

Transformation is via the cloned method.

§Examples

use orx_parallel::*;

fn warn(mut name: String) -> String {
    name.push('!');
    name
}

let names = vec![String::from("john"), String::from("doe")];

let new_names = names.par().cloned().map(warn).collect_vec();

assert_eq!(new_names, &[String::from("john!"), String::from("doe!")]);

Provided Methods§

Source

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

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

Transformation is via the cloned method.

§Examples
use orx_parallel::*;

fn warn(mut name: String) -> String {
    name.push('!');
    name
}

let names = vec![String::from("john"), String::from("doe")];

let new_names = names.par().cloned().map(warn).collect_vec();

assert_eq!(new_names, &[String::from("john!"), String::from("doe!")]);

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> ParIntoCloned<'a, T> for P
where T: Send + Sync + Clone + 'a, P: Par<Item = &'a T>,