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

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.

Implementations

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

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

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

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

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

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

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

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.