[][src]Struct mortal::sequence::SequenceMap

pub struct SequenceMap<K, V> { /* fields omitted */ }

Contains a set of string sequences, mapped to a value.

Methods

impl<K: AsRef<str>, V> SequenceMap<K, V>[src]

pub fn new() -> SequenceMap<K, V>[src]

Creates an empty SequenceMap.

pub fn with_capacity(n: usize) -> SequenceMap<K, V>[src]

Creates an empty SequenceMap with allocated capacity for n elements.

pub fn sequences(&self) -> &[(K, V)][src]

Returns a slice of all contained sequences, sorted by key.

pub fn sequences_mut(&mut self) -> &mut [(K, V)][src]

Returns a mutable slice of all contained sequences, sorted by key.

Note

Elements must remain sorted by key for the proper functioning of SequenceMap operations. If keys are modified, the caller must ensure that the slice is sorted.

pub fn entry(&mut self, key: K) -> Entry<K, V>[src]

Returns an Entry for the given key.

This API matches the entry API for the standard HashMap collection.

pub fn find(&self, key: &str) -> FindResult<&V>[src]

Performs a search for a partial or complete sequence match.

pub fn get(&self, key: &str) -> Option<&V>[src]

Returns the corresponding value for the given sequence.

pub fn get_mut(&mut self, key: &str) -> Option<&mut V>[src]

Returns a mutable reference to the corresponding value for the given sequence.

pub fn insert(&mut self, key: K, value: V) -> Option<V>[src]

Inserts a key-value pair into the map.

If the key already exists in the map, the new value will replace the old value and the old value will be returned.

pub fn remove(&mut self, key: &str) -> Option<(K, V)>[src]

Removes a key-value pair from the map.

Trait Implementations

impl<K: Clone, V: Clone> Clone for SequenceMap<K, V>[src]

impl<K: Debug, V: Debug> Debug for SequenceMap<K, V>[src]

impl<K: Default, V: Default> Default for SequenceMap<K, V>[src]

impl<K: AsRef<str>, V> From<Vec<(K, V)>> for SequenceMap<K, V>[src]

fn from(sequences: Vec<(K, V)>) -> SequenceMap<K, V>[src]

Creates a SequenceMap from a Vec of key-value pairs.

The input Vec will be sorted and deduplicated.

If two elements exist with the same key, the first element is used.

impl<K: AsRef<str>, V> FromIterator<(K, V)> for SequenceMap<K, V>[src]

fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self[src]

Creates a SequenceMap from an iterator of key-value pairs.

If two elements exist with the same key, the last element is used.

Auto Trait Implementations

impl<K, V> RefUnwindSafe for SequenceMap<K, V> where
    K: RefUnwindSafe,
    V: RefUnwindSafe

impl<K, V> Send for SequenceMap<K, V> where
    K: Send,
    V: Send

impl<K, V> Sync for SequenceMap<K, V> where
    K: Sync,
    V: Sync

impl<K, V> Unpin for SequenceMap<K, V> where
    K: Unpin,
    V: Unpin

impl<K, V> UnwindSafe for SequenceMap<K, V> where
    K: UnwindSafe,
    V: 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.