pub enum MaybeOwned<'a, T: 'a> {
Borrowed(&'a T),
Owned(T),
}
Variants§
Implementations§
Source§impl<'a, T: 'a> MaybeOwned<'a, T>
impl<'a, T: 'a> MaybeOwned<'a, T>
Source§impl<'a, T: 'a + Clone> MaybeOwned<'a, T>
impl<'a, T: 'a + Clone> MaybeOwned<'a, T>
Sourcepub fn unwrap_or_clone(self) -> T
pub fn unwrap_or_clone(self) -> T
Get the value, cloning if necessary.
Trait Implementations§
Source§impl<'a, T: 'a + Debug> Debug for MaybeOwned<'a, T>
impl<'a, T: 'a + Debug> Debug for MaybeOwned<'a, T>
Source§impl<'a, T: 'a + Default> Default for MaybeOwned<'a, T>
impl<'a, T: 'a + Default> Default for MaybeOwned<'a, T>
Source§fn default() -> MaybeOwned<'a, T>
fn default() -> MaybeOwned<'a, T>
Returns the “default value” for a type. Read more
Source§impl<'a, T: 'a + Display> Display for MaybeOwned<'a, T>
impl<'a, T: 'a + Display> Display for MaybeOwned<'a, T>
Source§impl<'a, T: 'a + Hash> Hash for MaybeOwned<'a, T>
impl<'a, T: 'a + Hash> Hash for MaybeOwned<'a, T>
Source§impl<'a, T: 'a + Ord> Ord for MaybeOwned<'a, T>
impl<'a, T: 'a + Ord> Ord for MaybeOwned<'a, T>
Source§fn cmp(&self, other: &MaybeOwned<'_, T>) -> Ordering
fn cmp(&self, other: &MaybeOwned<'_, T>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a, T: 'a + PartialEq> PartialEq for MaybeOwned<'a, T>
impl<'a, T: 'a + PartialEq> PartialEq for MaybeOwned<'a, T>
Source§fn eq(&self, other: &MaybeOwned<'_, T>) -> bool
fn eq(&self, other: &MaybeOwned<'_, T>) -> bool
Tests for
self
and other
values to be equal, and is used by ==
.Source§fn ne(&self, other: &MaybeOwned<'_, T>) -> bool
fn ne(&self, other: &MaybeOwned<'_, T>) -> bool
Tests for
!=
. The default implementation is almost always sufficient,
and should not be overridden without very good reason.Source§impl<'a, T: 'a + PartialOrd> PartialOrd for MaybeOwned<'a, T>
impl<'a, T: 'a + PartialOrd> PartialOrd for MaybeOwned<'a, T>
Source§fn partial_cmp(&self, other: &MaybeOwned<'_, T>) -> Option<Ordering>
fn partial_cmp(&self, other: &MaybeOwned<'_, T>) -> Option<Ordering>
Source§fn lt(&self, other: &MaybeOwned<'_, T>) -> bool
fn lt(&self, other: &MaybeOwned<'_, T>) -> bool
Source§fn le(&self, other: &MaybeOwned<'_, T>) -> bool
fn le(&self, other: &MaybeOwned<'_, T>) -> bool
Source§fn gt(&self, other: &MaybeOwned<'_, T>) -> bool
fn gt(&self, other: &MaybeOwned<'_, T>) -> bool
impl<'a, T: 'a + Eq> Eq for MaybeOwned<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for MaybeOwned<'a, T>where
T: Freeze,
impl<'a, T> RefUnwindSafe for MaybeOwned<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for MaybeOwned<'a, T>
impl<'a, T> Sync for MaybeOwned<'a, T>where
T: Sync,
impl<'a, T> Unpin for MaybeOwned<'a, T>where
T: Unpin,
impl<'a, T> UnwindSafe for MaybeOwned<'a, T>where
T: UnwindSafe + RefUnwindSafe,
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