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
enabled: bool
Enables code generation for this build method.
ident: &'a Ident
Name of this build fn.
visibility: &'a Visibility
Visibility of the build method, e.g. syn::Visibility::Public.
pattern: BuilderPattern
How the build method takes and returns self (e.g. mutably).
target_ty: &'a Ident
Type of the target field.
The corresonding builder field will be Option<field_type>.
target_ty_generics: Option<TyGenerics<'a>>
Type parameters and lifetimes attached to this builder struct.
initializers: Vec<Tokens>
Field initializers for the target type.
doc_comment: Option<Attribute>
Doc-comment of the builder struct.
bindings: Bindings
Bindings to libstd or libcore.
default_struct: Option<Block>
Default value for the whole struct.
This will be in scope for all initializers as __default.
validate_fn: Option<&'a Path>
Validation function with signature &FooBuilder -> Result<(), String>
to call before the macro-provided struct buildout.
Methods
impl<'a> BuildMethod<'a>[src]
fn doc_comment(&mut self, s: String) -> &mut Self
Set a doc-comment for this item.
fn push_initializer(&mut self, init: Initializer) -> &mut Self
Populate the BuildMethod with appropriate initializers of the
underlying struct.
For each struct field this must be called with the appropriate initializer.