diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2020-12-10 11:17:23 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2020-12-21 08:39:33 +0000 |
commit | 76b7d4eeb8c767186084d4fb51ff848ae89c7df1 (patch) | |
tree | 12729631a94cb828faf97c232e7dcc4f0d59db86 /subplotlib-derive | |
parent | 2e841608a19fe781220863d1fcca6c4868ca4812 (diff) | |
download | subplot-76b7d4eeb8c767186084d4fb51ff848ae89c7df1.tar.gz |
subplotlib: use state for context
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'subplotlib-derive')
-rw-r--r-- | subplotlib-derive/src/lib.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/subplotlib-derive/src/lib.rs b/subplotlib-derive/src/lib.rs index a92ab1c..adc0c01 100644 --- a/subplotlib-derive/src/lib.rs +++ b/subplotlib-derive/src/lib.rs @@ -251,19 +251,19 @@ fn process_step(input: ItemFn) -> proc_macro2::TokenStream { let stepnamestr = format!("{}", stepname); - let newfn = if mutablectx { - Ident::new("new_mutable", Span::call_site()) + let withfn = if mutablectx { + Ident::new("with_mut", Span::call_site()) } else { - Ident::new("new_immutable", Span::call_site()) + Ident::new("with", Span::call_site()) }; quote! { impl Builder { #(#fieldfns)* - pub fn build(self) -> ScenarioStep<#contexttype> { - ScenarioStep::#newfn(#stepnamestr, move |ctx| - #stepname(ctx, #(#buildargs),*)) + pub fn build(self) -> ScenarioStep { + ScenarioStep::new(#stepnamestr, move |ctx| + ctx.#withfn (|ctx| #stepname(ctx, #(#buildargs),*),false)) } } } |