pub struct InOutBuf<'inp, 'out, T> { /* private fields */ }
Expand description
Custom slice type which references one immutable (input) slice and one mutable (output) slice of equal length. Input and output slices are either the same or do not overlap.
Implementations§
source§impl<'inp, 'out, T> InOutBuf<'inp, 'out, T>
impl<'inp, 'out, T> InOutBuf<'inp, 'out, T>
sourcepub fn from_ref_mut(in_val: &'inp T, out_val: &'out mut T) -> Self
pub fn from_ref_mut(in_val: &'inp T, out_val: &'out mut T) -> Self
Create InOutBuf
from a pair of immutable and mutable references.
sourcepub fn new(
in_buf: &'inp [T],
out_buf: &'out mut [T],
) -> Result<Self, NotEqualError>
pub fn new( in_buf: &'inp [T], out_buf: &'out mut [T], ) -> Result<Self, NotEqualError>
Create InOutBuf
from immutable and mutable slices.
Returns an error if length of slices is not equal to each other.
sourcepub unsafe fn from_raw(
in_ptr: *const T,
out_ptr: *mut T,
len: usize,
) -> InOutBuf<'inp, 'out, T>
pub unsafe fn from_raw( in_ptr: *const T, out_ptr: *mut T, len: usize, ) -> InOutBuf<'inp, 'out, T>
Create InOutBuf
from raw input and output pointers.
§Safety
Behavior is undefined if any of the following conditions are violated:
in_ptr
must point to a properly initialized value of typeT
and must be valid for reads forlen * mem::size_of::<T>()
many bytes.out_ptr
must point to a properly initialized value of typeT
and must be valid for both reads and writes forlen * mem::size_of::<T>()
many bytes.in_ptr
andout_ptr
must be either equal or non-overlapping.- If
in_ptr
andout_ptr
are equal, then the memory referenced by them 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. - If
in_ptr
andout_ptr
are not equal, then the memory referenced byout_ptr
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 memory referenced byin_ptr
must not be mutated for the duration of lifetime'a
, except inside anUnsafeCell
. - The total size
len * mem::size_of::<T>()
must be no larger thanisize::MAX
.
sourcepub fn split_at(
self,
mid: usize,
) -> (InOutBuf<'inp, 'out, T>, InOutBuf<'inp, 'out, T>)
pub fn split_at( self, mid: usize, ) -> (InOutBuf<'inp, 'out, T>, InOutBuf<'inp, 'out, T>)
Divides one buffer into two at mid
index.
The first will contain all indices from [0, mid)
(excluding
the index mid
itself) and the second will contain all
indices from [mid, len)
(excluding the index len
itself).
§Panics
Panics if mid > len
.
sourcepub fn into_chunks<N: ArrayLength<T>>(
self,
) -> (InOutBuf<'inp, 'out, GenericArray<T, N>>, InOutBuf<'inp, 'out, T>)
pub fn into_chunks<N: ArrayLength<T>>( self, ) -> (InOutBuf<'inp, 'out, GenericArray<T, N>>, InOutBuf<'inp, 'out, T>)
Partition buffer into 2 parts: buffer of arrays and tail.