Struct parallel_vec::ParallelSlice
source · [−]#[repr(C)]pub struct ParallelSlice<'a, Param: ParallelParam> { /* private fields */ }Expand description
A immutable dynamically-sized view into a contiguous heterogeneous sequence. Contiguous here means that elements are laid out so that every element is the same distance from its neighbors.
Unlike a struct of slices, this type only stores one length instead of duplicating the values across multiple slice fields.
Implementations
sourceimpl<'a, Param: ParallelParam> ParallelSlice<'a, Param>
impl<'a, Param: ParallelParam> ParallelSlice<'a, Param>
sourcepub unsafe fn from_raw_parts(data: Param::Storage, len: usize) -> Self
pub unsafe fn from_raw_parts(data: Param::Storage, len: usize) -> Self
Forms a slice from a pointer and a length.
The len argument is the number of elements, not the number of bytes.
Safety
Behavior is undefined if any of the following conditions are violated:
-
datamust be valid for both reads and writes forlen * mem::size_of::<T>()many bytes, and it must be properly aligned. This means in particular:- The entire memory range of this slice must be contained within a single allocated object! Slices can never span across multiple allocated objects.
datamust be non-null and aligned even for zero-length slices. One reason for this is that enum layout optimizations may rely on references (including slices of any length) being aligned and non-null to distinguish them from other data. You can obtain a pointer that is usable asdatafor zero-length slices usingParallelParam::dangling().
-
datamust point tolenconsecutive properly initialized values of typeParam. -
The memory referenced by the returned slice must not be accessed through any other pointer (not derived from the return value) for the duration of lifetime
'a. Both read and write accesses are forbidden. -
The total size
len * mem::size_of::<T>()of the slice must be no larger thanisize::MAX.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements in the vector, also referred to as its ‘length’.
sourcepub fn get<'b: 'a, I: ParallelSliceIndex<Self>>(
&'b self,
index: I
) -> Option<I::Output>
pub fn get<'b: 'a, I: ParallelSliceIndex<Self>>(
&'b self,
index: I
) -> Option<I::Output>
Returns a immutable reference to the element at index, if available, or
None if it is out of bounds.
sourcepub fn first(&self) -> Option<Param::Ref>
pub fn first(&self) -> Option<Param::Ref>
Returns the first element of the slice, or None if it is empty.
sourcepub fn last(&self) -> Option<Param::Ref>
pub fn last(&self) -> Option<Param::Ref>
Returns the last element of the slice, or None if it is empty.
sourcepub fn index<I>(&self, index: I) -> I::Output where
I: ParallelSliceIndex<Self>,
pub fn index<I>(&self, index: I) -> I::Output where
I: ParallelSliceIndex<Self>,
Gets a immutable reference to the elements at index.
Panics
This function will panic if index is >= self.len.
sourcepub unsafe fn get_unchecked(&self, index: usize) -> Param::Ref
pub unsafe fn get_unchecked(&self, index: usize) -> Param::Ref
sourcepub fn iter(&self) -> Iter<'a, Param>ⓘNotable traits for Iter<'a, Param>impl<'a, Param: ParallelParam> Iterator for Iter<'a, Param> type Item = Param::Ref;
pub fn iter(&self) -> Iter<'a, Param>ⓘNotable traits for Iter<'a, Param>impl<'a, Param: ParallelParam> Iterator for Iter<'a, Param> type Item = Param::Ref;
Returns an iterator over the ParallelSlice.
sourcepub fn iters(&self) -> Param::Iters
pub fn iters(&self) -> Param::Iters
Returns an iterator over the ParallelSlice.
Trait Implementations
sourceimpl<'s, 'r, Param> Hash for ParallelSlice<'s, Param> where
Param: ParallelParam + 's,
Param::Ref: Hash,
'r: 's,
impl<'s, 'r, Param> Hash for ParallelSlice<'s, Param> where
Param: ParallelParam + 's,
Param::Ref: Hash,
'r: 's,
Auto Trait Implementations
impl<'a, Param> RefUnwindSafe for ParallelSlice<'a, Param> where
<Param as ParallelParam>::Storage: RefUnwindSafe,
impl<'a, Param> Send for ParallelSlice<'a, Param> where
<Param as ParallelParam>::Storage: Send,
impl<'a, Param> Sync for ParallelSlice<'a, Param> where
<Param as ParallelParam>::Storage: Sync,
impl<'a, Param> Unpin for ParallelSlice<'a, Param> where
<Param as ParallelParam>::Storage: Unpin,
impl<'a, Param> UnwindSafe for ParallelSlice<'a, Param> where
<Param as ParallelParam>::Storage: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more