Skip to content

Commit

Permalink
Add dbg_and_swallow macro to example
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasKalbertodt committed Mar 5, 2023
1 parent 612c815 commit 3f2d3ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/procmacro/examples/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use procmacro_example::{concat, repeat};
use procmacro_example::{concat, dbg_and_swallow, repeat};

const FOO: &str = concat!(r#"Hello "# '🦊' "\nHere is a friend: \u{1F427}");
// const FOO: &str = concat!(::);
Expand All @@ -8,6 +8,7 @@ const BAR: &str = repeat!(3 * "నా పిల్లి లావుగా ఉ
const BAZ: &str = repeat!(0b101 * "🦀");
// const BAZ: &str = repeat!(3.5 * "🦀");

dbg_and_swallow!(16px);

fn main() {
println!("{}", FOO);
Expand Down
8 changes: 8 additions & 0 deletions examples/procmacro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ use proc_macro::{Spacing, TokenStream, TokenTree};
use litrs::{Literal, IntegerLit, StringLit};


#[proc_macro]
pub fn dbg_and_swallow(input: TokenStream) -> TokenStream {
for token in input {
println!("{} -> {:#?}", token, Literal::try_from(&token));
}
TokenStream::new()
}

/// Concatinates all input string and char literals into a single output string
/// literal.
#[proc_macro]
Expand Down

0 comments on commit 3f2d3ee

Please sign in to comment.