Skip to content

Commit

Permalink
Allow setting build_fn-specific pattern
Browse files Browse the repository at this point in the history
This allows a builder to have mutating setters and an owned build method, removing the need to do clones during construction.

Fixes #321
  • Loading branch information
TedDriggs committed Jul 16, 2024
1 parent da455f6 commit 2a79a0a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion derive_builder_core/src/macro_options/darling_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ pub struct BuildFn {
skip: bool,
name: Ident,
validate: Option<Path>,
pattern: Option<BuilderPattern>,
#[darling(flatten)]
visibility: VisibilityAttr,
/// Either the path to an existing error type that the build method should return or a meta
Expand Down Expand Up @@ -189,6 +190,7 @@ impl Default for BuildFn {
BuildFn {
skip: false,
name: Ident::new("build", Span::call_site()),
pattern: None,
validate: None,
visibility: Default::default(),
error: None,
Expand Down Expand Up @@ -701,7 +703,7 @@ impl Options {
enabled: !self.build_fn.skip,
ident: &self.build_fn.name,
visibility: self.build_method_vis(),
pattern: self.pattern,
pattern: self.build_fn.pattern.unwrap_or(self.pattern),
target_ty: &self.ident,
target_ty_generics: Some(ty_generics),
error_ty: self.builder_error_ident(),
Expand Down

0 comments on commit 2a79a0a

Please sign in to comment.