From c8a363d76363999967191f6d37ace1b4b17df20a Mon Sep 17 00:00:00 2001 From: Martijn Faassen Date: Tue, 22 Oct 2024 16:12:30 +0200 Subject: [PATCH] It's almost not worth it here, but factor out preparation from token stream generation. --- crates/macros/src/constant.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/macros/src/constant.rs b/crates/macros/src/constant.rs index 3a9516c26b..ebc4bf1c2b 100644 --- a/crates/macros/src/constant.rs +++ b/crates/macros/src/constant.rs @@ -15,6 +15,13 @@ pub struct Constant { pub value: String, } +fn prepare(input: ItemConst) -> Result { + Ok(quote! { + #[allow(dead_code)] + #input + }) +} + pub fn parser(input: ItemConst) -> Result { let mut state = STATE.lock(); @@ -28,10 +35,7 @@ pub fn parser(input: ItemConst) -> Result { value: input.expr.to_token_stream().to_string(), }); - Ok(quote! { - #[allow(dead_code)] - #input - }) + prepare(input) } impl Constant {