Struct derive_builder_core::Builder [−][src]
pub struct Builder<'a> { pub enabled: bool, pub ident: Ident, pub pattern: BuilderPattern, pub derives: &'a [Path], pub generics: Option<&'a Generics>, pub visibility: Visibility, pub fields: Vec<TokenStream>, pub functions: Vec<TokenStream>, pub must_derive_clone: bool, 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: Ident
Name of this builder struct.
pattern: BuilderPattern
Pattern of this builder struct.
derives: &'a [Path]
Traits to automatically derive on the builder type.
generics: Option<&'a Generics>
Type parameters and lifetimes attached to this builder’s struct definition.
visibility: Visibility
Visibility of the builder struct, e.g. syn::Visibility::Public
.
fields: Vec<TokenStream>
Fields of the builder struct, e.g. foo: u32,
Expects each entry to be terminated by a comma.
functions: Vec<TokenStream>
Functions of the builder struct, e.g. fn bar() -> { unimplemented!() }
must_derive_clone: bool
Whether this builder must derive Clone
.
This is true even for a builder using the owned
pattern if there is a field whose setter
uses a different pattern.
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.
Implementations
impl<'a> Builder<'a>
[src]
impl<'a> Builder<'a>
[src]pub fn doc_comment(&mut self, s: String) -> &mut Self
[src]
Set a doc-comment for this item.
pub fn push_field(&mut self, f: BuilderField<'_>) -> &mut Self
[src]
Add a field to the builder
pub fn push_setter_fn(&mut self, f: Setter<'_>) -> &mut Self
[src]
Add a setter function to the builder
pub fn push_build_fn(&mut self, f: BuildMethod<'_>) -> &mut Self
[src]
Add final build function to the builder
Trait Implementations
impl<'a> ToTokens for Builder<'a>
[src]
impl<'a> ToTokens for Builder<'a>
[src]