Skip to main content

AnyMap

Trait AnyMap 

Source
pub trait AnyMap<K, V> {
    // Required methods
    fn len(&self) -> usize;
    fn insert(&mut self, key: K, value: V) -> Option<V>;
    fn get<Q>(&self, key: &Q) -> Option<&V>
       where K: Borrow<Q>,
             Q: Hash + Eq + ?Sized;
    fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
       where K: Borrow<Q>,
             Q: Hash + Eq + ?Sized;
    fn remove<Q>(&mut self, key: &Q) -> Option<V>
       where K: Borrow<Q>,
             Q: Hash + Eq + ?Sized;
    fn contains_key<Q>(&self, key: &Q) -> bool
       where K: Borrow<Q>,
             Q: Hash + Eq + ?Sized;
    fn clear(&mut self);

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A trait for abstraction over different map types (Stack, Heap, Small).

Required Methods§

Source

fn len(&self) -> usize

Returns the number of elements.

Source

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

Inserts the given key-value pair or element.

Source

fn get<Q>(&self, key: &Q) -> Option<&V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns a reference to the value corresponding to the key.

Source

fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns a reference to the value corresponding to the key.

Source

fn remove<Q>(&mut self, key: &Q) -> Option<V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Removes the specified element or key-value pair.

Source

fn contains_key<Q>(&self, key: &Q) -> bool
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns true if the collection contains the item or key.

Source

fn clear(&mut self)

Clears all elements from the collection.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if the collection is empty.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<K: Eq + Hash, V, S: BuildHasher> AnyMap<K, V> for HashMap<K, V, S>

Source§

fn len(&self) -> usize

Source§

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

Source§

fn get<Q>(&self, key: &Q) -> Option<&V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source§

fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source§

fn remove<Q>(&mut self, key: &Q) -> Option<V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source§

fn contains_key<Q>(&self, key: &Q) -> bool
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source§

fn clear(&mut self)

Source§

impl<K: Eq + Hash, V, S: BuildHasher> AnyMap<K, V> for HashMap<K, V, S>

Source§

fn len(&self) -> usize

Source§

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

Source§

fn get<Q>(&self, key: &Q) -> Option<&V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source§

fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source§

fn remove<Q>(&mut self, key: &Q) -> Option<V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source§

fn contains_key<Q>(&self, key: &Q) -> bool
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source§

fn clear(&mut self)

Source§

impl<K: Eq + Hash, V, S: BuildHasher> AnyMap<K, V> for OrderMap<K, V, S>

Source§

fn len(&self) -> usize

Source§

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

Source§

fn get<Q>(&self, key: &Q) -> Option<&V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source§

fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source§

fn remove<Q>(&mut self, key: &Q) -> Option<V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source§

fn contains_key<Q>(&self, key: &Q) -> bool
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source§

fn clear(&mut self)

Implementors§

Source§

impl<K: Eq + Hash, V, const N: usize> AnyMap<K, V> for HeaplessOrderedMap<K, V, N>

Source§

impl<K: Eq + Hash, V, const N: usize> AnyMap<K, V> for SmallOrderedMap<K, V, N>

Source§

impl<K: Eq + Hash, V, const N: usize> AnyMap<K, V> for SmallMap<K, V, N>