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.
Sourcepub unsafe fn to_view_slice_mut(
&mut self,
range: Range<usize>,
) -> ViewMutData<'a, T>
pub unsafe fn to_view_slice_mut( &mut self, range: Range<usize>, ) -> ViewMutData<'a, T>
A variant of StorageMut::slice_mut
which preserves the lifetime of
the slice.
§Safety
This is unsafe since this function cannot ensure that multiple references
to the same element are not created (by using get_mut
on self
and
the slice). It is up to the caller to prevent this.
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>
Source§unsafe fn assume_init(self) -> Self::Output
unsafe fn assume_init(self) -> Self::Output
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
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>
offset >= self.len()
. Read moreSource§unsafe fn get_unchecked(&self, offset: usize) -> &Self::Elem
unsafe fn get_unchecked(&self, offset: usize) -> &Self::Elem
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
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>
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
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>
Source§fn view_mut(&mut self) -> ViewMutData<'_, Self::Elem>
fn view_mut(&mut self) -> ViewMutData<'_, Self::Elem>
Source§unsafe fn as_slice_mut(&mut self) -> &mut [Self::Elem]
unsafe fn as_slice_mut(&mut self) -> &mut [Self::Elem]
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
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>
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>
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