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: impl ToString, ty: T) -> Self
where
T: Into<Type>,
{
Field {
name: name.to_string(),
ty: ty.into(),
documentation: String::new(),
annotation: Vec::new(),
value: String::new(),
visibility: None,
}
}
pub fn doc(&mut self, documentation: impl ToString) -> &mut Self {
self.documentation = documentation.to_string();
self
}
pub fn annotation(&mut self, annotation: impl ToString) -> &mut Self {
self.annotation.push(annotation.to_string());
self
}
pub fn vis(&mut self, visibility: impl ToString) -> &mut Self {
self.visibility = Some(visibility.to_string());
self
}
}