Enum bow::Bow [] [src]

pub enum Bow<'a, T: 'a + ToBox + ?Sized> {
    Borrowed(&'a T),
    Boxed(Box<T>),
}

Like a Cow, using ToBox instead of ToOwned.

Variants

Borrowed data.

Boxed data.

Methods

impl<'a, T: 'a + ToBox + ?Sized> Bow<'a, T>
[src]

[src]

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]);

[src]

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]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a, T: 'a + ToBox + ?Sized> Into<Box<T>> for Bow<'a, T>
[src]

[src]

Performs the conversion.

impl<'a, T: 'a + ToBox + ?Sized> Deref for Bow<'a, T>
[src]

The resulting type after dereferencing.

[src]

Dereferences the value.

impl<'a, T: 'a + ToBox + Debug + ?Sized> Debug for Bow<'a, T>
[src]

[src]

Formats the value using the given formatter.

impl<'a, T: 'a + ToBox + Display + ?Sized> Display for Bow<'a, T>
[src]

[src]

Formats the value using the given formatter. Read more

impl<'a, T: 'a + ToBox + ?Sized> Default for Bow<'a, T> where
    &'a T: Default
[src]

[src]

Returns the "default value" for a type. Read more

impl<'a, T: 'a + ToBox + ?Sized> AsRef<T> for Bow<'a, T>
[src]

[src]

Performs the conversion.

impl<'a, T: 'a + ToBox + ?Sized> Borrow<T> for Bow<'a, T>
[src]

[src]

Immutably borrows from an owned value. Read more

impl<'a, T: 'a + ToBox + ?Sized> From<&'a T> for Bow<'a, T>
[src]

[src]

Performs the conversion.

impl<'a, T: 'a + ToBox + ?Sized> From<Box<T>> for Bow<'a, T>
[src]

[src]

Performs the conversion.

impl<'a, T: 'a + ToBox + ToOwned + ?Sized> From<Cow<'a, T>> for Bow<'a, T> where
    <T as ToOwned>::Owned: Into<Box<T>>, 
[src]

[src]

Performs the conversion.

impl<'a, T: 'a + ToBox + ?Sized + PartialEq, U: AsRef<T>> PartialEq<U> for Bow<'a, T>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

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]

[src]

This method returns an ordering between self and other values if one exists. Read more

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

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 + ToBox + ?Sized + Ord> Ord for Bow<'a, T>
[src]

[src]

This method returns an Ordering between self and other. Read more

[src]

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the maximum of two values. Read more

[src]

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the minimum of two values. Read more

impl<'a, T: 'a + ToBox + ?Sized + Hash> Hash for Bow<'a, T>
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more