Skip to main content

NameMap

Struct NameMap 

Source
pub struct NameMap<V> { /* private fields */ }
Expand description

A mapping from Name to V.

Wraps HashMap<Name, V> for convenient use in the elaborator and kernel.

Implementations§

Source§

impl<V> NameMap<V>

Source

pub fn new() -> Self

Create an empty NameMap.

Source

pub fn with_capacity(cap: usize) -> Self

Create a NameMap with the given capacity.

Source

pub fn insert(&mut self, name: Name, value: V) -> Option<V>

Insert or overwrite a mapping.

Source

pub fn get(&self, name: &Name) -> Option<&V>

Get a reference to the value for name.

Source

pub fn get_mut(&mut self, name: &Name) -> Option<&mut V>

Get a mutable reference to the value for name.

Source

pub fn remove(&mut self, name: &Name) -> Option<V>

Remove and return the value for name.

Source

pub fn contains_key(&self, name: &Name) -> bool

Check whether name has a mapping.

Source

pub fn len(&self) -> usize

Number of mappings.

Source

pub fn is_empty(&self) -> bool

Returns true if empty.

Source

pub fn iter(&self) -> impl Iterator<Item = (&Name, &V)>

Iterate over key-value pairs.

Source

pub fn keys(&self) -> impl Iterator<Item = &Name>

Iterate over keys.

Source

pub fn values(&self) -> impl Iterator<Item = &V>

Iterate over values.

Source

pub fn filter_by_namespace(&self, ns: &Name) -> Vec<(&Name, &V)>

Filter entries by a predicate on the name.

Source

pub fn sorted_names(&self) -> Vec<Name>

Collect all names in sorted order.

Source

pub fn entry_or_insert(&mut self, name: Name, value: V) -> &mut V

Get or insert a default value.

Trait Implementations§

Source§

impl<V: Clone> Clone for NameMap<V>

Source§

fn clone(&self) -> NameMap<V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug> Debug for NameMap<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: Default> Default for NameMap<V>

Source§

fn default() -> NameMap<V>

Returns the “default value” for a type. Read more
Source§

impl<V> FromIterator<(Name, V)> for NameMap<V>

Source§

fn from_iter<I: IntoIterator<Item = (Name, V)>>(iter: I) -> Self

Creates a value from an iterator. Read more

Auto Trait Implementations§

§

impl<V> Freeze for NameMap<V>

§

impl<V> RefUnwindSafe for NameMap<V>
where V: RefUnwindSafe,

§

impl<V> Send for NameMap<V>
where V: Send,

§

impl<V> Sync for NameMap<V>
where V: Sync,

§

impl<V> Unpin for NameMap<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for NameMap<V>

§

impl<V> UnwindSafe for NameMap<V>
where V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.