Skip to content

Commit

Permalink
It's almost not worth it here, but factor out preparation from token …
Browse files Browse the repository at this point in the history
…stream generation.
  • Loading branch information
faassen committed Oct 22, 2024
1 parent 6e804b6 commit c8a363d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions crates/macros/src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ pub struct Constant {
pub value: String,
}

fn prepare(input: ItemConst) -> Result<TokenStream> {
Ok(quote! {
#[allow(dead_code)]
#input
})
}

pub fn parser(input: ItemConst) -> Result<TokenStream> {
let mut state = STATE.lock();

Expand All @@ -28,10 +35,7 @@ pub fn parser(input: ItemConst) -> Result<TokenStream> {
value: input.expr.to_token_stream().to_string(),
});

Ok(quote! {
#[allow(dead_code)]
#input
})
prepare(input)
}

impl Constant {
Expand Down

0 comments on commit c8a363d

Please sign in to comment.