Skip to content

Commit c8a363d

Browse files
committed
It's almost not worth it here, but factor out preparation from token stream generation.
1 parent 6e804b6 commit c8a363d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

crates/macros/src/constant.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ pub struct Constant {
1515
pub value: String,
1616
}
1717

18+
fn prepare(input: ItemConst) -> Result<TokenStream> {
19+
Ok(quote! {
20+
#[allow(dead_code)]
21+
#input
22+
})
23+
}
24+
1825
pub fn parser(input: ItemConst) -> Result<TokenStream> {
1926
let mut state = STATE.lock();
2027

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

31-
Ok(quote! {
32-
#[allow(dead_code)]
33-
#input
34-
})
38+
prepare(input)
3539
}
3640

3741
impl Constant {

0 commit comments

Comments
 (0)