pub struct RxHashMap<K, V>(_)
where
         K: Clone + Eq + Hash,
         V: Clone + 'static;
Expand description

A reactive version of Vec that uses nested reactivity on its elements. This requires nothing by Clone + 'static of the elements inside the map, and it wraps them in RcSignals to make them reactive. If you want to store nested reactive types inside the map (e.g. Strings), you should use super::RxHashMapNested.

Methods from Deref<Target = HashMap<K, V>>§

1.0.0 · source

pub fn capacity(&self) -> usize

Returns the number of elements the map can hold without reallocating.

This number is a lower bound; the HashMap<K, V> might be able to hold more, but is guaranteed to be able to hold at least this many.

Examples
use std::collections::HashMap;
let map: HashMap<i32, i32> = HashMap::with_capacity(100);
assert!(map.capacity() >= 100);
1.0.0 · source

pub fn keys(&self) -> Keys<'_, K, V>

An iterator visiting all keys in arbitrary order. The iterator element type is &'a K.

Examples
use std::collections::HashMap;

let map = HashMap::from([
    ("a", 1),
    ("b", 2),
    ("c", 3),
]);

for key in map.keys() {
    println!("{key}");
}
Performance

In the current implementation, iterating over keys takes O(capacity) time instead of O(len) because it internally visits empty buckets too.

1.0.0 · source

pub fn values(&self) -> Values<'_, K, V>

An iterator visiting all values in arbitrary order. The iterator element type is &'a V.

Examples
use std::collections::HashMap;

let map = HashMap::from([
    ("a", 1),
    ("b", 2),
    ("c", 3),
]);

for val in map.values() {
    println!("{val}");
}
Performance

In the current implementation, iterating over values takes O(capacity) time instead of O(len) because it internally visits empty buckets too.

1.0.0 · source

pub fn iter(&self) -> Iter<'_, K, V>

An iterator visiting all key-value pairs in arbitrary order. The iterator element type is (&'a K, &'a V).

Examples
use std::collections::HashMap;

let map = HashMap::from([
    ("a", 1),
    ("b", 2),
    ("c", 3),
]);

for (key, val) in map.iter() {
    println!("key: {key} val: {val}");
}
Performance

In the current implementation, iterating over map takes O(capacity) time instead of O(len) because it internally visits empty buckets too.

1.0.0 · source

pub fn len(&self) -> usize

Returns the number of elements in the map.

Examples
use std::collections::HashMap;

let mut a = HashMap::new();
assert_eq!(a.len(), 0);
a.insert(1, "a");
assert_eq!(a.len(), 1);
1.0.0 · source

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

Examples
use std::collections::HashMap;

let mut a = HashMap::new();
assert!(a.is_empty());
a.insert(1, "a");
assert!(!a.is_empty());
1.9.0 · source

pub fn hasher(&self) -> &S

Returns a reference to the map’s BuildHasher.

Examples
use std::collections::HashMap;
use std::collections::hash_map::RandomState;

let hasher = RandomState::new();
let map: HashMap<i32, i32> = HashMap::with_hasher(hasher);
let hasher: &RandomState = map.hasher();
1.0.0 · source

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

Returns a reference to the value corresponding to the key.

The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

Examples
use std::collections::HashMap;

let mut map = HashMap::new();
map.insert(1, "a");
assert_eq!(map.get(&1), Some(&"a"));
assert_eq!(map.get(&2), None);
1.40.0 · source

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

Returns the key-value pair corresponding to the supplied key.

The supplied key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

Examples
use std::collections::HashMap;

let mut map = HashMap::new();
map.insert(1, "a");
assert_eq!(map.get_key_value(&1), Some((&1, &"a")));
assert_eq!(map.get_key_value(&2), None);
1.0.0 · source

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

Returns true if the map contains a value for the specified key.

The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

Examples
use std::collections::HashMap;

let mut map = HashMap::new();
map.insert(1, "a");
assert_eq!(map.contains_key(&1), true);
assert_eq!(map.contains_key(&2), false);
source

pub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>

🔬This is a nightly-only experimental API. (hash_raw_entry)

Creates a raw immutable entry builder for the HashMap.

Raw entries provide the lowest level of control for searching and manipulating a map. They must be manually initialized with a hash and then manually searched.

This is useful for

  • Hash memoization
  • Using a search key that doesn’t work with the Borrow trait
  • Using custom comparison logic without newtype wrappers

Unless you are in such a situation, higher-level and more foolproof APIs like get should be preferred.

Immutable raw entries have very limited use; you might instead want raw_entry_mut.

Trait Implementations§

source§

impl<K, V> Clone for RxHashMap<K, V>where K: Clone + Eq + Hash + Clone, V: Clone + 'static + Clone,

source§

fn clone(&self) -> RxHashMap<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, V> Debug for RxHashMap<K, V>where K: Clone + Eq + Hash + Debug, V: Clone + 'static + Debug,

source§

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

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

impl<K, V> Deref for RxHashMap<K, V>where K: Clone + Serialize + DeserializeOwned + Eq + Hash, V: Clone + Serialize + DeserializeOwned + 'static,

§

type Target = HashMap<K, V, RandomState>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'de, K, V> Deserialize<'de> for RxHashMap<K, V>where K: Clone + Eq + Hash + Deserialize<'de>, V: Clone + 'static + Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<K, V> From<HashMap<K, V, RandomState>> for RxHashMap<K, V>where K: Clone + Serialize + DeserializeOwned + Eq + Hash, V: Clone + Serialize + DeserializeOwned + 'static,

source§

fn from(value: HashMap<K, V>) -> Self

Converts to this type from the input type.
source§

impl<K, V> MakeRx for RxHashMap<K, V>where K: Clone + Serialize + DeserializeOwned + Eq + Hash, V: Clone + Serialize + DeserializeOwned + 'static,

§

type Rx = RxHashMapRx<K, V>

The type of the reactive version that we’ll convert to. By having this as an associated type, we can associate the reactive type with the unreactive, meaning greater inference and fewer arguments that the user needs to provide to macros.
source§

fn make_rx(self) -> Self::Rx

Transforms an instance of the struct into its reactive version.
source§

const HSR_IGNORE: bool = false

This should be set to true to have this type be ignored by the hot state reloading system, which can be useful when working with state that you will regularly update in development. Read more
source§

impl<K, V> PartialEq<RxHashMap<K, V>> for RxHashMap<K, V>where K: Clone + Eq + Hash + PartialEq, V: Clone + 'static + PartialEq,

source§

fn eq(&self, other: &RxHashMap<K, V>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K, V> Serialize for RxHashMap<K, V>where K: Clone + Eq + Hash + Serialize, V: Clone + 'static + Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<K, V> Eq for RxHashMap<K, V>where K: Clone + Eq + Hash + Eq, V: Clone + 'static + Eq,

source§

impl<K, V> StructuralEq for RxHashMap<K, V>where K: Clone + Eq + Hash, V: Clone + 'static,

source§

impl<K, V> StructuralPartialEq for RxHashMap<K, V>where K: Clone + Eq + Hash, V: Clone + 'static,

Auto Trait Implementations§

§

impl<K, V> RefUnwindSafe for RxHashMap<K, V>where K: RefUnwindSafe, V: RefUnwindSafe,

§

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

§

impl<K, V> Sync for RxHashMap<K, V>where K: Sync, V: Sync,

§

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

§

impl<K, V> UnwindSafe for RxHashMap<K, V>where K: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,