pub trait FromExactParallelSink {
type Item: Send;
type Sink: ExactParallelSink<Item = Self::Item> + Sync;
// Required method
unsafe fn finalize(sink: Self::Sink) -> Self;
}Expand description
Trait for collecting items from an ExactParallelSink.
You most likely won’t need to interact with this trait directly, as it is
only used to express output types of the
collect() and
try_collect() adaptors on
BaseExactParallelIterator. You can
however implement this trait if you want to allow your types to be collected
by these adaptors.
Required Associated Types§
Sourcetype Sink: ExactParallelSink<Item = Self::Item> + Sync
type Sink: ExactParallelSink<Item = Self::Item> + Sync
Sink from which this type can be created.
Required Methods§
Sourceunsafe fn finalize(sink: Self::Sink) -> Self
unsafe fn finalize(sink: Self::Sink) -> Self
Converts a fully populated sink into this type.
§Safety
- This can only be called after all indices have been passed once and
only once to the sink’s
push_item(). - No call to
skip_item_range()must have been made on the sink (otherwise, you need to callcancel()instead).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<T> FromExactParallelSink for Box<[T]>where
T: Send,
use std::ops::Deref;
let boxed_slice: Box<[_]> = (1..=10)
.into_par_iter()
.with_thread_pool(&mut thread_pool)
.collect();
assert_eq!(boxed_slice.deref(), &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
impl<T> FromExactParallelSink for Box<[T]>where
T: Send,
use std::ops::Deref;
let boxed_slice: Box<[_]> = (1..=10)
.into_par_iter()
.with_thread_pool(&mut thread_pool)
.collect();
assert_eq!(boxed_slice.deref(), &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);Source§impl<T> FromExactParallelSink for Vec<T>where
T: Send,
impl<T> FromExactParallelSink for Vec<T>where
T: Send,
Source§impl<T> FromExactParallelSink for VecDeque<T>where
T: Send,
use std::collections::VecDeque;
let vec_deque: VecDeque<_> = (1..=10)
.into_par_iter()
.with_thread_pool(&mut thread_pool)
.collect();
assert_eq!(
vec_deque.as_slices(),
(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10][..], &[][..])
);
impl<T> FromExactParallelSink for VecDeque<T>where
T: Send,
use std::collections::VecDeque;
let vec_deque: VecDeque<_> = (1..=10)
.into_par_iter()
.with_thread_pool(&mut thread_pool)
.collect();
assert_eq!(
vec_deque.as_slices(),
(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10][..], &[][..])
);