Re-exported from alloc::collections::hashmap::OwnedMap!.
forall K, V.
exposed struct OwnedMap! {
inner: exists 'm. (Exclusive!['m], HashMap![K, V, 'm]),
}
A HashMap! packaged with its capability, for a map kept across calls or in a loop variable without naming its brand. Each method opens the package, calls the HashMap! method and repacks the result under whatever brand it returned. inner is the package itself: open it for the branded API and pack it back afterwards.
Methods
method newsource
fn new(seed: Seed) -> OwnedMap![K, V] { ... }
An empty map that hashes its keys under seed, aborting when allocation fails.
method try_newsource
fn try_new(seed: Seed) -> Result[OwnedMap![K, V], AllocError] { ... }
An empty map that hashes its keys under seed, or the allocation failure: HashMap!::try_new's map, packaged.
method lensource
fn len(&self) -> usize { ... }
How many entries the map holds.
method is_emptysource
fn is_empty(&self) -> bool { ... }
Whether the map holds no entries.
method drainsource
fn drain(self) -> exists 'm. Drain![K, V, 'm] { ... }
Every entry, moved out, in no particular order (see HashMap!::drain).
method destroy_withsource
fn destroy_with(self, f: fn(K, V) -> ()) -> () { ... }
Frees the map, handing each entry to f first.
method eachsource
forall Env where Copy[Env].
fn each(&self, f: closure[Env](&_: K, &_: V) -> ()) { ... }
Calls f on each key and its value where they live, in no particular order, keeping the map (HashMap!::each).
method each_insource
forall C, Env where Copy[Env].
fn each_in(&self, &cx: C, f: closure[Env](&_: K, &_: V, &_: C) -> ()) { ... }
each, with a context cx lent to f beside each key and value (HashMap!::each_in).
method clear_withsource
fn clear_with(&self, f: fn(K, V) -> ()) { ... }
Removes every entry, handing each to f, and keeps the room the map has (HashMap!::clear_with).
method insertsource
fn insert(&self, key: K, val: V) -> Option[(K, V)] { ... }
Stores val under key, handing back the key and value it replaces.
method removesource
fn remove(&self, &key: K) -> Option[(K, V)] { ... }
Removes key's entry, handing back its stored key and value.
method containssource
fn contains(&self, &key: K) -> bool { ... }
Whether key is in the map.
method withsource
forall Ret, Env where Copy[Env].
fn with(&self, &key: K, f: closure[Env](V) -> (V, Ret)) -> Option[Ret] { ... }
Calls f on key's value in place: f takes the value and hands it back with a result. When the key is absent f is dropped uncalled, so what it captures must be Copy.
method updatesource
forall Ret, Env where Copy[Env].
fn update(&self, &key: K, f: closure[Env](&_: V) -> Ret) -> Option[Ret] { ... }
Calls f on key's value where it lives: f gets it through &, and nothing is copied out or back. When the key is absent f is dropped uncalled, so what it captures must be Copy.
method update_insource
forall C, Ret, Env where Copy[Env].
fn update_in(&self, &key: K, &cx: C, f: closure[Env](&_: V, &_: C) -> Ret) -> Option[Ret] { ... }
Calls f on key's value where it lives, with a context cx lent beside it: update, with the linear values f works on, which it cannot capture.
method find_withsource
forall Q, Ret, Env where Hash[Q], Eq[K, Q], Copy[Env].
fn find_with(&self, &probe: Q, f: closure[Env](V) -> (V, Ret)) -> Option[Ret] { ... }
Calls f on the value of the key probe stands for, in place: with, looked up by a probe of another type that hashes like the keys and compares equal to the one it stands for (HashMap!::find), such as a core::slice::Readable view for a Buffer! key, so that no owned key is built for the lookup. The probe comes back.
method find_updatesource
forall Q, Ret, Env where Hash[Q], Eq[K, Q], Copy[Env].
fn find_update(&self, &probe: Q, f: closure[Env](&_: V) -> Ret) -> Option[Ret] { ... }
Calls f on the value of the key probe stands for, where it lives: update, looked up by a probe as find_with is.
method findsource
forall Q where Hash[Q], Eq[K, Q].
fn find(&self, &probe: Q) -> Option[V] { ... }
A copy of the value of the key probe stands for, or None: get, looked up by a probe as find_with is.
method getsource
fn get(&self, &key: K) -> Option[V] { ... }
A copy of key's value, or None when it is absent.
method atsource
fn at(&self, &key: K) -> V { ... }
A copy of the value of a key that must be in the map; without it, the program stops (core::process::trap).
method insert_insource
forall C where HashIn[K, C].
fn insert_in(&self, &cx: C, key: K, val: V) -> Option[V] { ... }
Stores val under the domain key key, handing back the value it replaces. This is insert for a Copy key that points into a domain, hashed and compared through that domain's capability cx.
method remove_insource
forall C where HashIn[K, C].
fn remove_in(&self, &cx: C, key: K) -> Option[V] { ... }
Removes a domain key's entry, handing back its value: remove for a domain key.
method contains_insource
forall C where HashIn[K, C].
fn contains_in(&self, &cx: C, key: K) -> bool { ... }
Whether a domain key is in the map: contains for a domain key.
method with_insource
forall C, Ret, Env where HashIn[K, C], Copy[Env].
fn with_in(&self, &cx: C, key: K, f: closure[Env](V) -> (V, Ret)) -> Option[Ret] { ... }
Calls f on a domain key's value in place: with for a domain key.
method get_insource
forall C where HashIn[K, C].
fn get_in(&self, &cx: C, key: K) -> Option[V] { ... }
A copy of a domain key's value, or None when it is absent: get for a domain key.
method clearsource
fn clear(&self) { ... }
Removes every entry, keeping the room the map has.
method destroysource
fn destroy(self) -> () { ... }
Frees a map of Copy keys and values, which need no per-entry callback.