Enum ordered_multimap::list_ordered_multimap::KeyWrapper [−][src]
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.
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());
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
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
Mutably borrows from an owned value. Read more
impl<T> CallHasher for T where
T: Hash,
impl<T> CallHasher for T where
T: Hash,
pub fn vzip(self) -> V