Struct derive_builder_core::BuildMethod [] [src]

pub struct BuildMethod<'a> {
    pub enabled: bool,
    pub ident: &'a Ident,
    pub visibility: &'a Visibility,
    pub pattern: BuilderPattern,
    pub target_ty: &'a Ident,
    pub target_ty_generics: Option<TyGenerics<'a>>,
    pub initializers: Vec<Tokens>,
    pub doc_comment: Option<Attribute>,
    pub bindings: Bindings,
    pub default_struct: Option<Block>,
    pub validate_fn: Option<&'a Path>,
}

Initializer for the struct fields in the build method, implementing quote::ToTokens.

Examples

Will expand to something like the following (depending on settings):

pub fn build(&self) -> ::std::result::Result<Foo, ::std::string::String> {
    Ok(Foo {
        foo: self.foo,
    })
}

Fields

Enables code generation for this build method.

Name of this build fn.

Visibility of the build method, e.g. syn::Visibility::Public.

How the build method takes and returns self (e.g. mutably).

Type of the target field.

The corresonding builder field will be Option<field_type>.

Type parameters and lifetimes attached to this builder struct.

Field initializers for the target type.

Doc-comment of the builder struct.

Bindings to libstd or libcore.

Default value for the whole struct.

This will be in scope for all initializers as __default.

Validation function with signature &FooBuilder -> Result<(), String> to call before the macro-provided struct buildout.

Methods

impl<'a> BuildMethod<'a>
[src]

[src]

Set a doc-comment for this item.

[src]

Populate the BuildMethod with appropriate initializers of the underlying struct.

For each struct field this must be called with the appropriate initializer.

Trait Implementations

impl<'a> Debug for BuildMethod<'a>
[src]

[src]

Formats the value using the given formatter.

impl<'a> ToTokens for BuildMethod<'a>
[src]

[src]

Write self to the given Tokens. Read more