pub enum TryCow<'a, B>where
B: 'a + TryToOwned + ?Sized,{
Borrowed(&'a B),
Owned(<B as TryToOwned>::Owned),
}Expand description
Like [std::borrow::Cow] but returns OutOfMemory errors for various
APIs that force allocation of an owned copy.
Variants§
Implementations§
Source§impl<'a, B> TryCow<'a, B>where
B: TryToOwned + ?Sized,
impl<'a, B> TryCow<'a, B>where
B: TryToOwned + ?Sized,
Sourcepub fn to_mut(&mut self) -> Result<&mut <B as TryToOwned>::Owned, OutOfMemory>
pub fn to_mut(&mut self) -> Result<&mut <B as TryToOwned>::Owned, OutOfMemory>
Same as [std::borrow::Cow::to_mut] but returns an OutOfMemory
error on allocation failure.
Sourcepub fn into_owned(self) -> Result<<B as TryToOwned>::Owned, OutOfMemory>
pub fn into_owned(self) -> Result<<B as TryToOwned>::Owned, OutOfMemory>
Same as [std::borrow::Cow::into_owned] but returns an OutOfMemory
error on allocation failure.
Trait Implementations§
Source§impl<B> Ord for TryCow<'_, B>
impl<B> Ord for TryCow<'_, B>
Source§impl<B> PartialOrd for TryCow<'_, B>
impl<B> PartialOrd for TryCow<'_, B>
Source§impl<B> TryClone for TryCow<'_, B>where
B: ?Sized + TryToOwned,
impl<B> TryClone for TryCow<'_, B>where
B: ?Sized + TryToOwned,
Source§fn try_clone(&self) -> Result<Self, OutOfMemory>
fn try_clone(&self) -> Result<Self, OutOfMemory>
Attempt to clone
self, returning an error if any allocation fails
during cloning.Source§fn clone_panic_on_oom(&self) -> Self
fn clone_panic_on_oom(&self) -> Self
Clone
self, panicking on allocation failure.impl<B> Eq for TryCow<'_, B>
Auto Trait Implementations§
impl<'a, B> Freeze for TryCow<'a, B>
impl<'a, B> RefUnwindSafe for TryCow<'a, B>
impl<'a, B> Send for TryCow<'a, B>
impl<'a, B> Sync for TryCow<'a, B>
impl<'a, B> Unpin for TryCow<'a, B>
impl<'a, B> UnsafeUnpin for TryCow<'a, B>
impl<'a, B> UnwindSafe for TryCow<'a, B>
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> TryToOwned for Twhere
T: TryClone,
impl<T> TryToOwned for Twhere
T: TryClone,
Source§fn try_to_owned(&self) -> Result<<T as TryToOwned>::Owned, OutOfMemory>
fn try_to_owned(&self) -> Result<<T as TryToOwned>::Owned, OutOfMemory>
Try to allocate an owned version of
self.