Struct derive_builder_core::Builder
[−]
[src]
pub struct Builder<'a> { pub enabled: bool, pub ident: &'a Ident, pub pattern: BuilderPattern, pub derives: &'a [Ident], pub generics: Option<&'a Generics>, pub visibility: &'a Visibility, pub fields: Vec<Tokens>, pub functions: Vec<Tokens>, pub doc_comment: Option<Attribute>, pub deprecation_notes: DeprecationNotes, pub bindings: Bindings, }
Builder, implementing quote::ToTokens
.
Examples
Will expand to something like the following (depending on settings):
#[derive(Default, Clone)] pub struct FooBuilder { foo: u32, } #[allow(dead_code)] impl FooBuilder { fn bar () -> { unimplemented!() } }
Fields
enabled: bool
Enables code generation for this builder struct.
ident: &'a Ident
Name of this builder struct.
pattern: BuilderPattern
Pattern of this builder struct.
derives: &'a [Ident]
Traits to automatically derive on the builder type.
generics: Option<&'a Generics>
Type parameters and lifetimes attached to this builder's struct definition.
visibility: &'a Visibility
Visibility of the builder struct, e.g. syn::Visibility::Public
.
fields: Vec<Tokens>
Fields of the builder struct, e.g. foo: u32,
Expects each entry to be terminated by a comma.
functions: Vec<Tokens>
Functions of the builder struct, e.g. fn bar() -> { unimplemented!() }
doc_comment: Option<Attribute>
Doc-comment of the builder struct.
deprecation_notes: DeprecationNotes
Emit deprecation notes to the user.
bindings: Bindings
Library bindings to use in emitted builder.
Methods
impl<'a> Builder<'a>
[src]
fn doc_comment(&mut self, s: String) -> &mut Self
Set a doc-comment for this item.
fn push_field(&mut self, f: BuilderField) -> &mut Self
Add a field to the builder
fn push_setter_fn(&mut self, f: Setter) -> &mut Self
Add a setter function to the builder
fn push_build_fn(&mut self, f: BuildMethod) -> &mut Self
Add final build function to the builder