Trait Map

Source
pub trait Map {
    type Key;
    type Val;

    // Required methods
    fn len(&self) -> usize;
    fn with_capacity(capacity: usize) -> Self;
    fn capacity(&self) -> usize;
    fn mem_size(&self) -> usize;
    fn contains(&self, key: &Self::Key) -> bool;
    fn get(&self, key: &Self::Key) -> Option<&Self::Val>;
    fn get_mut(&mut self, key: &Self::Key) -> Option<&mut Self::Val>;
    unsafe fn get_unchecked(&self, key: &Self::Key) -> &Self::Val;
    unsafe fn get_unchecked_mut(&mut self, key: &Self::Key) -> &mut Self::Val;
    unsafe fn remove_unchecked(&mut self, key: &Self::Key) -> Self::Val;
    fn insert(&mut self, key: Self::Key, val: Self::Val) -> Option<Self::Val>;
    fn remove(&mut self, key: &Self::Key) -> Option<Self::Val>;
}
Expand description

Map接口定义

Required Associated Types§

Required Methods§

Source

fn len(&self) -> usize

Source

fn with_capacity(capacity: usize) -> Self

Source

fn capacity(&self) -> usize

Source

fn mem_size(&self) -> usize

Source

fn contains(&self, key: &Self::Key) -> bool

Source

fn get(&self, key: &Self::Key) -> Option<&Self::Val>

Source

fn get_mut(&mut self, key: &Self::Key) -> Option<&mut Self::Val>

Source

unsafe fn get_unchecked(&self, key: &Self::Key) -> &Self::Val

Source

unsafe fn get_unchecked_mut(&mut self, key: &Self::Key) -> &mut Self::Val

Source

unsafe fn remove_unchecked(&mut self, key: &Self::Key) -> Self::Val

Source

fn insert(&mut self, key: Self::Key, val: Self::Val) -> Option<Self::Val>

Source

fn remove(&mut self, key: &Self::Key) -> Option<Self::Val>

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.

Implementors§

Source§

impl<K: Hash + Eq, V> Map for HashMap<K, V>

Source§

type Key = K

Source§

type Val = V

Source§

impl<T> Map for VecMap<T>

为VecMap实现Map

Source§

impl<T, const N: usize> Map for SmallVecMap<T, N>

为SmallVecMap实现Map

Source§

type Key = u32

Source§

type Val = T