Enum TryCow
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§
§impl<'a, B> TryCow<'a, B>where
B: TryToOwned + ?Sized,
impl<'a, B> TryCow<'a, B>where
B: TryToOwned + ?Sized,
pub 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.
pub 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§
§impl<B> AsRef<B> for TryCow<'_, B>where
B: TryToOwned + ?Sized,
impl<B> AsRef<B> for TryCow<'_, B>where
B: TryToOwned + ?Sized,
§impl<'a, B> Borrow<B> for TryCow<'a, B>where
B: TryToOwned + ?Sized,
impl<'a, B> Borrow<B> for TryCow<'a, B>where
B: TryToOwned + ?Sized,
§impl<B> Deref for TryCow<'_, B>where
B: TryToOwned + ?Sized,
impl<B> Deref for TryCow<'_, B>where
B: TryToOwned + ?Sized,
§impl<B> Ord for TryCow<'_, B>
impl<B> Ord for TryCow<'_, B>
§impl<B> PartialOrd for TryCow<'_, B>
impl<B> PartialOrd for TryCow<'_, B>
§impl<B> TryClone for TryCow<'_, B>where
B: TryToOwned + ?Sized,
impl<B> TryClone for TryCow<'_, B>where
B: TryToOwned + ?Sized,
§fn try_clone(&self) -> Result<TryCow<'_, B>, OutOfMemory>
fn try_clone(&self) -> Result<TryCow<'_, B>, OutOfMemory>
Attempt to clone
self, returning an error if any allocation fails
during cloning.§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> 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
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> TryToOwned for Twhere
T: TryClone,
impl<T> TryToOwned for Twhere
T: TryClone,
§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.