1use crate::r#type::Type;
2
3#[derive(Debug, Clone)]
5pub struct Field {
6 pub name: String,
8
9 pub ty: Type,
11
12 pub documentation: Vec<String>,
14
15 pub annotation: Vec<String>,
17}
18
19impl Field {
20 pub fn new<T>(name: &str, ty: T) -> Self
22 where
23 T: Into<Type>,
24 {
25 Self {
26 name: name.into(),
27 ty: ty.into(),
28 documentation: Vec::new(),
29 annotation: Vec::new(),
30 }
31 }
32
33 pub fn doc(&mut self, documentation: Vec<&str>) -> &mut Self {
35 self.documentation = documentation.iter().map(|doc| doc.to_string()).collect();
36 self
37 }
38
39 pub fn annotation(&mut self, annotation: Vec<&str>) -> &mut Self {
41 self.annotation = annotation.iter().map(|ann| ann.to_string()).collect();
42 self
43 }
44}