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.
Trait Implementations§
Source§impl<T, A: Allocator> ConstDefault for Cow<'_, T, A>
impl<T, A: Allocator> ConstDefault for Cow<'_, T, A>
Source§impl<'a, T: Clone, A: AllocatorDefault> FromIterator<T> for Cow<'a, [T], A>
impl<'a, T: Clone, A: AllocatorDefault> FromIterator<T> for Cow<'a, [T], A>
Source§impl<'a, 'b, T, A: Allocator, U: ToOwnedIn<B> + ?Sized, B: Allocator> PartialEq<Cow<'b, U, B>> for Cow<'a, T, A>
impl<'a, 'b, T, A: Allocator, U: ToOwnedIn<B> + ?Sized, B: Allocator> PartialEq<Cow<'b, U, B>> for Cow<'a, T, A>
impl<'a, T: ToOwnedIn<A> + Eq + ?Sized, A: Allocator> Eq for Cow<'a, T, A>
Auto Trait Implementations§
impl<'b, T, A> Freeze for Cow<'b, T, A>
impl<'b, T, A> RefUnwindSafe for Cow<'b, T, A>
impl<'b, T, A> Send for Cow<'b, T, A>
impl<'b, T, A> Sync for Cow<'b, T, A>
impl<'b, T, A> Unpin for Cow<'b, T, A>
impl<'b, T, A> UnwindSafe for Cow<'b, T, A>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)