Struct php_codegen::body::Body
source ยท pub struct Body {
pub factory: Option<Box<dyn Fn(Indentation, usize) -> String>>,
pub semicolon_for_empty: bool,
}
Fieldsยง
ยงfactory: Option<Box<dyn Fn(Indentation, usize) -> String>>
ยงsemicolon_for_empty: bool
Implementationsยง
sourceยงimpl Body
impl Body
pub fn with_factory<T: Fn(Indentation, usize) -> String + 'static>(
factory: T
) -> Self
sourcepub fn with_semicolon_for_empty(self, semicolon_for_empty: bool) -> Self
pub fn with_semicolon_for_empty(self, semicolon_for_empty: bool) -> Self
Examples found in repository?
More examples
src/function.rs (line 25)
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 59 60
pub fn new<T: ToString>(name: T) -> Self {
Self {
name: name.to_string(),
parameters: vec![],
return_type: None,
body: Body::new().with_semicolon_for_empty(false),
attributes: vec![],
documentation: None,
}
}
pub fn document(mut self, documentation: Document) -> Self {
self.documentation = Some(documentation);
self
}
pub fn attributes(mut self, attributes: AttributeGroup) -> Self {
self.attributes.push(attributes);
self
}
pub fn parameter(mut self, parameter: Parameter) -> Self {
self.parameters.push(parameter);
self
}
pub fn returns(mut self, return_type: DataType) -> Self {
self.return_type = Some(return_type);
self
}
pub fn body<T: Into<Body>>(mut self, body: T) -> Self {
self.body = body.into();
self.body = self.body.with_semicolon_for_empty(false);
self
}