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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use crate::r#type::Type;
#[derive(Debug, Clone)]
pub struct Field {
pub name: String,
pub ty: Type,
pub documentation: String,
pub annotation: Vec<String>,
pub value: String,
pub visibility: Option<String>,
}
impl Field {
pub fn new<T>(name: &str, ty: T) -> Self
where
T: Into<Type>,
{
Field {
name: name.into(),
ty: ty.into(),
documentation: String::new(),
annotation: Vec::new(),
value: String::new(),
visibility: None,
}
}
pub fn doc(&mut self, documentation: impl Into<String>) -> &mut Self {
self.documentation = documentation.into();
self
}
pub fn annotation(&mut self, annotation: impl Into<String>) -> &mut Self {
self.annotation.push(annotation.into());
self
}
pub fn vis(&mut self, visibility: impl Into<String>) -> &mut Self {
self.visibility = Some(visibility.into());
self
}
}