Skip to content

Commit 5940df6

Browse files
committed
Add builder methods to avoid verbose construction
1 parent 00881a4 commit 5940df6

File tree

7 files changed

+805
-549
lines changed

7 files changed

+805
-549
lines changed

time-macros/src/format_description/public/modifier.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,15 @@ macro_rules! to_tokens {
3131
}
3232

3333
let mut tokens = quote_! {
34-
let mut value = $struct_name::default();
34+
$struct_name::default()
3535
};
3636
$(
3737
#[allow(clippy::redundant_pattern_matching)]
3838
if !matches!($field_name, $default) {
39-
quote_append!(tokens value.$field_name =);
40-
$field_name.append_to(&mut tokens);
41-
quote_append!(tokens ;);
39+
let method_name = Ident::new(concat!("with_", stringify!($field_name)), Span::mixed_site());
40+
quote_append!(tokens .#(method_name)(#S($field_name)));
4241
}
4342
)*
44-
quote_append!(tokens value);
4543

4644
TokenTree::Group(Group::new(
4745
Delimiter::Brace,

0 commit comments

Comments
 (0)