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ยง

Examples found in repository?
src/function.rs (line 25)
20
21
22
23
24
25
26
27
28
29
    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,
        }
    }
Examples found in repository?
src/method.rs (line 94)
93
94
95
96
97
    pub fn body<T: Into<Body>>(mut self, body: T) -> Self {
        self.body = body.into().with_semicolon_for_empty(true);

        self
    }
More examples
Hide additional 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
    }

Trait Implementationsยง

Formats the value using the given formatter. Read more
Returns the โ€œdefault valueโ€ for a type. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.

Auto Trait Implementationsยง

Blanket Implementationsยง

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.