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
use linked_hash_map::LinkedHashMap;
use super::ElementDef;
use super::PropertyDef;
pub type KeyMap<V> = LinkedHashMap<String, V>;
pub trait Addable<V: Key> {
fn add(&mut self, new_value: V);
}
impl<V: Key> Addable<V> for KeyMap<V> {
fn add(&mut self, value: V) {
self.insert(value.get_key(), value);
}
}
pub trait Key {
fn get_key(&self) -> String;
}
impl Key for ElementDef {
fn get_key(&self) -> String {
self.name.clone()
}
}
impl Key for PropertyDef {
fn get_key(&self) -> String {
self.name.clone()
}
}