Struct derive_builder_core::BuildMethod[][src]

pub struct BuildMethod<'a> {
    pub enabled: bool,
    pub ident: &'a Ident,
    pub visibility: Visibility,
    pub pattern: BuilderPattern,
    pub target_ty: &'a Ident,
    pub target_ty_generics: Option<TypeGenerics<'a>>,
    pub initializers: Vec<TokenStream>,
    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: 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<TypeGenerics<'a>>

Type parameters and lifetimes attached to this builder struct.

initializers: Vec<TokenStream>

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.

Implementations

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

pub fn doc_comment(&mut self, s: String) -> &mut Self[src]

Set a doc-comment for this item.

pub fn push_initializer(&mut self, init: Initializer<'_>) -> &mut Self[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]

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

Auto Trait Implementations

impl<'a> RefUnwindSafe for BuildMethod<'a>

impl<'a> !Send for BuildMethod<'a>

impl<'a> !Sync for BuildMethod<'a>

impl<'a> Unpin for BuildMethod<'a>

impl<'a> UnwindSafe for BuildMethod<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Spanned for T where
    T: Spanned + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.