Struct miri::MonoHashMap

source ·
pub struct MonoHashMap<K: Hash + Eq, V>(RefCell<FxHashMap<K, Box<V>>>);

Tuple Fields§

§0: RefCell<FxHashMap<K, Box<V>>>

Implementations§

source§

impl<K: Hash + Eq, V> MonoHashMap<K, V>

source

pub fn iter<T>( &self, f: impl FnOnce(&mut dyn Iterator<Item = (&K, &V)>) -> T ) -> T

This function exists for priroda to be able to iterate over all evaluator memory.

The function is somewhat roundabout with the closure argument because internally the MonoHashMap uses a RefCell. When iterating over the FxHashMap inside the RefCell, we need to keep a borrow to the FxHashMap inside the iterator. The borrow is only alive as long as the Ref returned by RefCell::borrow() is alive. So we can’t return the iterator, as that would drop the Ref. We can’t return both, as it’s not possible in Rust to have a struct/tuple with a field that refers to another field.

Trait Implementations§

source§

impl<K: Hash + Eq, V> AllocMap<K, V> for MonoHashMap<K, V>

source§

fn get_or<E>( &self, k: K, vacant: impl FnOnce() -> Result<V, E> ) -> Result<&V, E>

The most interesting method: Providing a shared reference without holding the RefCell open, and inserting new data if the key is not used yet. vacant is called if the key is not found in the map; if it returns a reference, that is used directly, if it returns owned data, that is put into the map and returned.

source§

fn get(&self, k: K) -> Option<&V>

Read-only lookup (avoid read-acquiring the RefCell).

source§

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

Tests if the map contains the given key. Deliberately takes &mut because that is sufficient, and some implementations can be more efficient then (using RefCell::get_mut).
source§

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

Callers should prefer AllocMap::contains_key when it is possible to call because it may be more efficient. This function exists for callers that only have a shared reference (which might make it slightly less efficient than contains_key, e.g. if the data is stored inside a RefCell).
source§

fn insert(&mut self, k: K, v: V) -> Option<V>

Inserts a new entry into the map.
source§

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

Removes an entry from the map.
source§

fn filter_map_collect<T>(&self, f: impl FnMut(&K, &V) -> Option<T>) -> Vec<T>

Returns data based on the keys and values in the map.
source§

fn get_mut_or<E>( &mut self, k: K, vacant: impl FnOnce() -> Result<V, E> ) -> Result<&mut V, E>

Returns a mutable reference to entry k. If no such entry exists, call vacant and either forward its error, or add its result to the map and return a reference to that.
source§

fn get_mut(&mut self, k: K) -> Option<&mut V>

Mutable lookup.
source§

impl<K: Clone + Hash + Eq, V: Clone> Clone for MonoHashMap<K, V>

source§

fn clone(&self) -> MonoHashMap<K, V>

Returns a copy 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<K: Debug + Hash + Eq, V: Debug> Debug for MonoHashMap<K, V>

source§

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

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

impl<K: Hash + Eq, V> Default for MonoHashMap<K, V>

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<K, V> !RefUnwindSafe for MonoHashMap<K, V>

§

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

§

impl<K, V> !Sync for MonoHashMap<K, V>

§

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

§

impl<K, V> UnwindSafe for MonoHashMap<K, V>
where K: UnwindSafe, 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> 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 40 bytes