pub struct ViewData<'a, T> { /* private fields */ }
Expand description
Storage for an immutable tensor view.
This has the same representation in memory as a slice: a pointer and a length. Unlike a slice it allows for other mutable storage to reference memory ranges that overlap with this one. It is up to APIs built on top of this to ensure uniqueness of mutable element references.
Implementations§
Source§impl<'a, T> ViewData<'a, T>
impl<'a, T> ViewData<'a, T>
Sourcepub unsafe fn get_unchecked(&self, offset: usize) -> &'a T
pub unsafe fn get_unchecked(&self, offset: usize) -> &'a T
Sourcepub fn slice(&self, range: Range<usize>) -> ViewData<'a, T>
pub fn slice(&self, range: Range<usize>) -> ViewData<'a, T>
Variant of Storage::slice
which preserves lifetimes.
Sourcepub fn view(&self) -> ViewData<'a, T>
pub fn view(&self) -> ViewData<'a, T>
Variant of Storage::view
which preserves lifetimes.
Trait Implementations§
Source§impl<'a, T> AssumeInit for ViewData<'a, MaybeUninit<T>>
impl<'a, T> AssumeInit for ViewData<'a, MaybeUninit<T>>
Source§impl<T> Storage for ViewData<'_, T>
impl<T> Storage for ViewData<'_, T>
Source§const MUTABLE: bool = false
const MUTABLE: bool = false
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 moreimpl<T> Copy for ViewData<'_, T>
impl<T> Send for ViewData<'_, T>
impl<T> Sync for ViewData<'_, T>
Auto Trait Implementations§
impl<'a, T> Freeze for ViewData<'a, T>
impl<'a, T> RefUnwindSafe for ViewData<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Unpin for ViewData<'a, T>
impl<'a, T> UnwindSafe for ViewData<'a, T>where
T: RefUnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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