pub enum Cow<'b, T: ToOwnedIn<A> + ?Sized, A: Allocator> {
Borrowed(&'b T),
Owned(Owned<T, A>),
}
Expand description
Representation of either an owned or borrowed instance of a type.
Variants§
Implementations§
Source§impl<'b, T: ToOwnedIn<A> + ?Sized, A: Allocator> Cow<'b, T, A>
impl<'b, T: ToOwnedIn<A> + ?Sized, A: Allocator> Cow<'b, T, A>
Sourcepub fn is_borrowed(&self) -> bool
pub fn is_borrowed(&self) -> bool
Determine if this instance is borrowed.
Sourcepub fn to_mut(&mut self) -> &mut Owned<T, A>
pub fn to_mut(&mut self) -> &mut Owned<T, A>
If necessary, convert self
into an owned instance. Return a mutable reference
to the owned instance.
Sourcepub fn to_mut_in<I>(&mut self, alloc_in: I) -> &mut Owned<T, A>where
I: AllocateIn<Alloc = A>,
pub fn to_mut_in<I>(&mut self, alloc_in: I) -> &mut Owned<T, A>where
I: AllocateIn<Alloc = A>,
If necessary, convert self
into an owned instance given an allocation target.
Return a mutable reference to the owned instance.
Sourcepub fn into_owned(self) -> Owned<T, A>
pub fn into_owned(self) -> Owned<T, A>
If necessary, convert self
into an owned instance. Unwrap and return the
owned instance.
Sourcepub fn into_owned_in<I>(self, alloc_in: I) -> Owned<T, A>where
I: AllocateIn<Alloc = A>,
pub fn into_owned_in<I>(self, alloc_in: I) -> Owned<T, A>where
I: AllocateIn<Alloc = A>,
If necessary, convert self
into an owned instance given an allocation target.
Unwrap and return the owned instance.
Sourcepub fn try_into_owned(self) -> Result<Owned<T, A>, StorageError>
pub fn try_into_owned(self) -> Result<Owned<T, A>, StorageError>
If necessary, try to convert self
into an owned instance.
Unwrap and return the owned instance or a storage error.
Sourcepub fn try_into_owned_in<I>(
self,
storage: I,
) -> Result<Owned<T, A>, StorageError>where
I: AllocateIn<Alloc = A>,
pub fn try_into_owned_in<I>(
self,
storage: I,
) -> Result<Owned<T, A>, StorageError>where
I: AllocateIn<Alloc = A>,
If necessary, try to convert self
into an owned instance given an allocation
target. Unwrap and return the owned instance or a storage error.