pub enum CowData<'a, T> {
Owned(Vec<T>),
Borrowed(ViewData<'a, T>),
}
Expand description
Tensor storage which may be either owned or borrowed.
The name is taken from std::borrow::Cow
in the standard library,
which is conceptually similar.
Variants§
Trait Implementations§
Source§impl<T> Storage for CowData<'_, T>
impl<T> Storage for CowData<'_, 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 moreAuto Trait Implementations§
impl<'a, T> Freeze for CowData<'a, T>
impl<'a, T> RefUnwindSafe for CowData<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for CowData<'a, T>where
T: Send,
impl<'a, T> Sync for CowData<'a, T>where
T: Sync,
impl<'a, T> Unpin for CowData<'a, T>where
T: Unpin,
impl<'a, T> UnwindSafe for CowData<'a, T>where
T: RefUnwindSafe + UnwindSafe,
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