pub trait ParIntoCloned<'a, T>: Par<Item = &'a T>{
// 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§
Sourcefn cloned(self) -> impl Par<Item = T>
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.