use crate::r#type::Type;
#[derive(Debug, Clone)]
pub struct Field {
pub name: String,
pub ty: Type,
pub documentation: Vec<String>,
pub annotation: Vec<String>,
}
impl Field {
pub fn new<T>(name: &str, ty: T) -> Self
where
T: Into<Type>,
{
Self {
name: name.into(),
ty: ty.into(),
documentation: Vec::new(),
annotation: Vec::new(),
}
}
pub fn doc(&mut self, documentation: Vec<&str>) -> &mut Self {
self.documentation = documentation.iter().map(|doc| doc.to_string()).collect();
self
}
pub fn annotation(&mut self, annotation: Vec<&str>) -> &mut Self {
self.annotation = annotation.iter().map(|ann| ann.to_string()).collect();
self
}
}