[][src]Enum ordered_multimap::list_ordered_multimap::KeyWrapper

pub enum KeyWrapper<'map, Key> {
    Borrowed(&'map Key),
    Owned(Key),
}

A wrapper around a key that is either borrowed or owned.

This type is similar to std::borrow::Cow but does not require a Clone trait bound on the key.

Variants

Borrowed(&'map Key)

An immutable reference to a key. This implies that the key is still associated to at least one value in the multimap.

Owned(Key)

An owned key. This will occur when a key is no longer associated with any values in the multimap.

Methods

impl<'map, Key> KeyWrapper<'map, Key>[src]

pub fn into_owned(self) -> Key where
    Key: Clone
[src]

If the key wrapped is owned, it is returned. Otherwise, the borrowed key is cloned and returned.

Examples

use ordered_multimap::list_ordered_multimap::KeyWrapper;

let borrowed = KeyWrapper::Borrowed(&0);
assert_eq!(borrowed.into_owned(), 0);

let owned = KeyWrapper::Owned(0);
assert_eq!(borrowed.into_owned(), 0);

pub fn is_borrowed(&self) -> bool[src]

Returns whether the wrapped key is borrowed.

Examples

use ordered_multimap::list_ordered_multimap::KeyWrapper;

let borrowed = KeyWrapper::Borrowed(&0);
assert!(borrowed.is_borrowed());

let owned = KeyWrapper::Owned(0);
assert!(!owned.is_borrowed());

pub fn is_owned(&self) -> bool[src]

Returns whether the wrapped key is owned.

Examples

use ordered_multimap::list_ordered_multimap::KeyWrapper;

let borrowed = KeyWrapper::Borrowed(&0);
assert!(!borrowed.is_owned());

let owned = KeyWrapper::Owned(0);
assert!(owned.is_owned());

Trait Implementations

impl<'map, Key: Clone> Clone for KeyWrapper<'map, Key>[src]

impl<'map, Key: Copy> Copy for KeyWrapper<'map, Key>[src]

impl<'map, Key: Debug> Debug for KeyWrapper<'map, Key>[src]

impl<'map, Key: Eq> Eq for KeyWrapper<'map, Key>[src]

impl<'map, Key: Hash> Hash for KeyWrapper<'map, Key>[src]

impl<'map, Key: PartialEq> PartialEq<KeyWrapper<'map, Key>> for KeyWrapper<'map, Key>[src]

impl<'map, Key> StructuralEq for KeyWrapper<'map, Key>[src]

impl<'map, Key> StructuralPartialEq for KeyWrapper<'map, Key>[src]

Auto Trait Implementations

impl<'map, Key> RefUnwindSafe for KeyWrapper<'map, Key> where
    Key: RefUnwindSafe

impl<'map, Key> Send for KeyWrapper<'map, Key> where
    Key: Send + Sync

impl<'map, Key> Sync for KeyWrapper<'map, Key> where
    Key: Sync

impl<'map, Key> Unpin for KeyWrapper<'map, Key> where
    Key: Unpin

impl<'map, Key> UnwindSafe for KeyWrapper<'map, Key> where
    Key: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,