pub struct ViewMutData<'a, T> { /* private fields */ }
Expand description
Storage for a mutable tensor view.
This has the same representation in memory as a mutable slice: a pointer and a length. Unlike a slice it allows for other storage objects to reference memory ranges that overlap with this one. It is up to APIs built on top of this to ensure uniqueness of mutable references.
Implementations§
Source§impl<'a, T> ViewMutData<'a, T>
impl<'a, T> ViewMutData<'a, T>
Sourcepub unsafe fn to_slice_mut(self) -> &'a mut [T]
pub unsafe fn to_slice_mut(self) -> &'a mut [T]
Variant of StorageMut::as_slice_mut
which preserves the underlying
lifetime in the result.
§Safety
Sourcepub fn split_mut(
self,
left: Range<usize>,
right: Range<usize>,
) -> (ViewMutData<'a, T>, ViewMutData<'a, T>)
pub fn split_mut( self, left: Range<usize>, right: Range<usize>, ) -> (ViewMutData<'a, T>, ViewMutData<'a, T>)
Split the storage into two sub-views.
Unlike splitting a slice, this does not ensure that the two halves do not overlap, only that the “left” and “right” ranges are valid.
Trait Implementations§
Source§impl<'a, T> AssumeInit for ViewMutData<'a, MaybeUninit<T>>
impl<'a, T> AssumeInit for ViewMutData<'a, MaybeUninit<T>>
Source§type Output = ViewMutData<'a, T>
type Output = ViewMutData<'a, T>
The type of the initialized storage.
Source§unsafe fn assume_init(self) -> Self::Output
unsafe fn assume_init(self) -> Self::Output
Cast
self
to a collection of initialized values. Read moreSource§impl<'a, T: Debug> Debug for ViewMutData<'a, T>
impl<'a, T: Debug> Debug for ViewMutData<'a, T>
Source§impl<T> Storage for ViewMutData<'_, T>
impl<T> Storage for ViewMutData<'_, T>
Source§const MUTABLE: bool = true
const MUTABLE: bool = true
True if this storage allows mutable access via
StorageMut
. This is
used to determine if a layout can be safely used with a storage.
Layouts where multiple indices map to the same offset must not be used
with mutable storage.Source§unsafe fn get(&self, offset: usize) -> Option<&Self::Elem>
unsafe fn get(&self, offset: usize) -> Option<&Self::Elem>
Return the element at a given offset, or None if
offset >= self.len()
. Read moreSource§unsafe fn get_unchecked(&self, offset: usize) -> &Self::Elem
unsafe fn get_unchecked(&self, offset: usize) -> &Self::Elem
Return a reference to the element at
offset
. Read moreSource§impl<T> StorageMut for ViewMutData<'_, T>
impl<T> StorageMut for ViewMutData<'_, T>
Source§fn as_mut_ptr(&mut self) -> *mut T
fn as_mut_ptr(&mut self) -> *mut T
Return a mutable pointer to the first element in storage.
Source§unsafe fn get_mut(&mut self, offset: usize) -> Option<&mut Self::Elem>
unsafe fn get_mut(&mut self, offset: usize) -> Option<&mut Self::Elem>
Mutable version of
Storage::get
. Read moreSource§unsafe fn get_unchecked_mut(&mut self, offset: usize) -> &mut Self::Elem
unsafe fn get_unchecked_mut(&mut self, offset: usize) -> &mut Self::Elem
Mutable version of
Storage::get_unchecked
. Read moreSource§fn slice_mut(&mut self, range: Range<usize>) -> ViewMutData<'_, Self::Elem>
fn slice_mut(&mut self, range: Range<usize>) -> ViewMutData<'_, Self::Elem>
Return a slice of this storage.
Source§fn view_mut(&mut self) -> ViewMutData<'_, Self::Elem>
fn view_mut(&mut self) -> ViewMutData<'_, Self::Elem>
Return a mutable view of this storage.
Source§unsafe fn as_slice_mut(&mut self) -> &mut [Self::Elem]
unsafe fn as_slice_mut(&mut self) -> &mut [Self::Elem]
Return the stored elements as a mutable slice. Read more
impl<T> Send for ViewMutData<'_, T>
Auto Trait Implementations§
impl<'a, T> Freeze for ViewMutData<'a, T>
impl<'a, T> RefUnwindSafe for ViewMutData<'a, T>where
T: RefUnwindSafe,
impl<'a, T> !Sync for ViewMutData<'a, T>
impl<'a, T> Unpin for ViewMutData<'a, T>
impl<'a, T> !UnwindSafe for ViewMutData<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more