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
41
42
use super::*;
use alloc::string::String;
use hashbrown::HashMap;
pub trait TypeDescriptionContainer {
fn new() -> Self;
fn contains_type(&self, type_name: &str) -> bool;
fn reserve_type_name(&mut self, type_name: String) {
self.insert(type_name, TypeDescription::PLACEHOLDER);
}
fn insert(&mut self, type_name: String, type_description: TypeDescription);
fn insert_all(&mut self, other: &Self);
}
#[derive(Debug, Default)]
pub struct TypeDescriptionContainerImpl(pub HashMap<String, TypeDescription>);
impl TypeDescriptionContainer for TypeDescriptionContainerImpl {
fn new() -> Self {
TypeDescriptionContainerImpl(HashMap::new())
}
fn contains_type(&self, type_name: &str) -> bool {
self.0.contains_key(type_name)
}
fn insert(&mut self, type_name: String, type_description: TypeDescription) {
self.0.insert(type_name, type_description);
}
fn insert_all(&mut self, other: &Self) {
for (key, value) in other.0.iter() {
self.0.insert(key.clone(), value.clone());
}
}
}