1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use std::collections::HashMap;
use std::fmt;
use std::ops::{Deref, DerefMut};
pub type EventAttribFn = std::rc::Rc<dyn AsRef<wasm_bindgen::JsValue>>;
pub struct Events(pub HashMap<String, EventAttribFn>);
impl PartialEq for Events {
fn eq(&self, _rhs: &Self) -> bool {
true
}
}
impl fmt::Debug for Events {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let events: String = self.0.keys().map(|key| " ".to_string() + key).collect();
write!(f, "{}", events)
}
}
impl Deref for Events {
type Target = HashMap<String, EventAttribFn>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for Events {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}