pub unsafe trait StorageMut: Storage {
// Required method
fn as_mut_ptr(&mut self) -> *mut Self::Elem;
// Provided methods
unsafe fn get_mut(&mut self, offset: usize) -> Option<&mut Self::Elem> { ... }
unsafe fn get_unchecked_mut(&mut self, offset: usize) -> &mut Self::Elem { ... }
fn slice_mut(&mut self, range: Range<usize>) -> ViewMutData<'_, Self::Elem> { ... }
fn view_mut(&mut self) -> ViewMutData<'_, Self::Elem> { ... }
unsafe fn as_slice_mut(&mut self) -> &mut [Self::Elem] { ... }
}Expand description
Trait for backing storage used by mutable tensors and views.
This extends Storage with methods to get mutable pointers and references
to elements in the storage.
§Safety
The as_mut_ptr method has the same safety
requirements as Storage::as_ptr. The result of as_mut_ptr must also
be equal to as_ptr.
Required Methods§
Sourcefn as_mut_ptr(&mut self) -> *mut Self::Elem
fn as_mut_ptr(&mut self) -> *mut Self::Elem
Return a mutable pointer to the first element in storage.
Provided Methods§
Sourceunsafe 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.
§Safety
This has the same requirement as get_mut plus
the caller must ensure that offset < self.len().
Sourcefn 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.
Sourcefn view_mut(&mut self) -> ViewMutData<'_, Self::Elem>
fn view_mut(&mut self) -> ViewMutData<'_, Self::Elem>
Return a mutable view of this storage.
Sourceunsafe 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.
§Safety
The caller must ensure that the storage is contiguous (ie. no unused elements) and that there are no other references to any elements in the storage.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.