Enum bow::Bow
[−]
[src]
pub enum Bow<'a, T: 'a + ToBox + ?Sized> { Borrowed(&'a T), Boxed(Box<T>), }
Variants
Borrowed(&'a T)
Borrowed data.
Boxed(Box<T>)
Boxed data.
Methods
impl<'a, T: 'a + ToBox + ?Sized> Bow<'a, T>
[src]
fn to_mut(&mut self) -> &mut T
Acquires a mutable reference to the data.
Boxes the data if it is not already boxed.
Examples
use bow::Bow; let slice = &[3, 2, 1]; let mut bow: Bow<[_]> = Bow::Borrowed(slice); bow.to_mut().sort(); assert_eq!(bow, &[1, 2, 3]);
fn into_box(self) -> Box<T>
Extracts the data as a box.
Boxes the data if it is not already boxed.
Examples
use bow::Bow; let slice = &[3, 2, 1]; let mut bow: Bow<[_]> = Bow::Borrowed(slice); let boxed: Box<[_]> = bow.into_box();
Trait Implementations
impl<'a, T: 'a + ToBox + ?Sized> Clone for Bow<'a, T>
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<'a, T: 'a + ToBox + ?Sized> Into<Box<T>> for Bow<'a, T>
[src]
impl<'a, T: 'a + ToBox + ?Sized> Deref for Bow<'a, T>
[src]
type Target = T
The resulting type after dereferencing
fn deref(&self) -> &T
The method called to dereference a value
impl<'a, T: 'a + ToBox + Debug + ?Sized> Debug for Bow<'a, T>
[src]
impl<'a, T: 'a + ToBox + Display + ?Sized> Display for Bow<'a, T>
[src]
impl<'a, T: 'a + ToBox + ?Sized> Default for Bow<'a, T> where
&'a T: Default,
[src]
&'a T: Default,
impl<'a, T: 'a + ToBox + ?Sized> AsRef<T> for Bow<'a, T>
[src]
fn as_ref(&self) -> &T
Performs the conversion.
impl<'a, T: 'a + ToBox + ?Sized> Borrow<T> for Bow<'a, T>
[src]
impl<'a, T: 'a + ToBox + ?Sized> From<&'a T> for Bow<'a, T>
[src]
impl<'a, T: 'a + ToBox + ?Sized> From<Box<T>> for Bow<'a, T>
[src]
impl<'a, T: 'a + ToBox + ToOwned + ?Sized> From<Cow<'a, T>> for Bow<'a, T> where
<T as ToOwned>::Owned: Into<Box<T>>,
[src]
<T as ToOwned>::Owned: Into<Box<T>>,
impl<'a, T: 'a + ToBox + ?Sized + PartialEq, U: AsRef<T>> PartialEq<U> for Bow<'a, T>
[src]
fn eq(&self, rhs: &U) -> bool
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
This method tests for !=
.
impl<'a, T: 'a + ToBox + ?Sized + Eq> Eq for Bow<'a, T>
[src]
impl<'a, T: 'a + ToBox + ?Sized + PartialOrd, U: AsRef<T>> PartialOrd<U> for Bow<'a, T>
[src]
fn partial_cmp(&self, rhs: &U) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
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
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
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
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<'a, T: 'a + ToBox + ?Sized + Ord> Ord for Bow<'a, T>
[src]
fn cmp(&self, rhs: &Bow<'a, T>) -> Ordering
This method returns an Ordering
between self
and other
. Read more