async_component_components/
map.rs1use std::{
2 collections::{hash_map::RandomState, HashMap},
3 hash::Hash,
4 ops::{Deref, DerefMut},
5};
6
7use async_component_core::AsyncComponent;
8
9#[derive(Debug)]
10pub struct HashMapComponent<K, V, S = RandomState>(pub HashMap<K, V, S>);
11
12impl<K, V, S> Deref for HashMapComponent<K, V, S> {
13 type Target = HashMap<K, V, S>;
14
15 fn deref(&self) -> &Self::Target {
16 &self.0
17 }
18}
19
20impl<K, V, S> DerefMut for HashMapComponent<K, V, S> {
21 fn deref_mut(&mut self) -> &mut Self::Target {
22 &mut self.0
23 }
24}
25
26impl<K: Eq + Hash, V: AsyncComponent, S> AsyncComponent for HashMapComponent<K, V, S> {
27 fn update_component(&mut self) {
28 for value in self.0.values_mut() {
29 value.update_component();
30 }
31 }
32}