Enum boow::Bow
[−]
[src]
pub enum Bow<'a, T: 'a> { Owned(T), Borrowed(&'a T), }
Borrow-Or-oWned smart pointer.
[Bow
] implements [Deref
], which means that you can call non-mutating
methods directly on the data it encloses. If mutation is desired,
borrow_mut
will obtain some mutable reference to an owned value, but
only if it is owned.
Variants
Owned(T)
Borrowed(&'a T)
Methods
impl<'a, T: 'a> Bow<'a, T>
[src]
pub fn borrow_mut(&mut self) -> Option<&mut T>
[src]
Get a mutable reference to the enclosed value. Return [None
] if the
value is not owned.
pub fn extract(self) -> Option<T>
[src]
Consume the enclosed value and return it if it is owned.
Trait Implementations
impl<'a, T: Copy + 'a> Copy for Bow<'a, T>
[src]
impl<'a, T: Clone + 'a> Clone for Bow<'a, T>
[src]
fn clone(&self) -> Bow<'a, T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a, T: 'a> Borrow<T> for Bow<'a, T>
[src]
impl<'a, T: 'a> Deref for Bow<'a, T>
[src]
type Target = T
The resulting type after dereferencing.
fn deref(&self) -> &T
[src]
Dereferences the value.
impl<'a, T: 'a> Eq for Bow<'a, T> where
T: Eq,
[src]
T: Eq,
impl<'a, T: 'a> Ord for Bow<'a, T> where
T: Ord,
[src]
T: Ord,
fn cmp(&self, other: &Bow<'a, T>) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl<'a, T: 'a> PartialEq for Bow<'a, T> where
T: PartialEq,
[src]
T: PartialEq,
fn eq(&self, other: &Bow<'a, T>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'a, T: 'a> PartialOrd for Bow<'a, T> where
T: PartialOrd,
[src]
T: PartialOrd,
fn partial_cmp(&self, other: &Bow<'a, T>) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<'a, T: 'a> Debug for Bow<'a, T> where
T: Debug,
[src]
T: Debug,
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<'a, T: 'a> Display for Bow<'a, T> where
T: Display,
[src]
T: Display,
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<'a, T: 'a> Default for Bow<'a, T> where
T: Default,
[src]
T: Default,
impl<'a, T: 'a> Hash for Bow<'a, T> where
T: Hash,
[src]
T: Hash,
fn hash<H: Hasher>(&self, state: &mut H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more