#c-like #concat #macro

macro c-like-concat

simple macro that works just like C's ##

6 releases

0.0.5 May 31, 2024
0.0.4 Dec 24, 2022
0.0.3 Oct 3, 2022
0.0.2 Nov 5, 2021

#358 in Procedural macros

GPL-3.0 license

3KB

Simple macro that works just like C's ##

The exception is that it uses the `~` sign instead of `##`

Example

use c_like_concat::concat;

#[derive(Debug, Eq, PartialEq)]
struct FuzzBuzz;

fn main() {
    assert_eq!(concat!(0 ~ x ~ 42), 0x42);
    assert_eq!(concat!(Fuzz ~ Buzz), FuzzBuzz);
    // Sadly, but following code works
    // as `stringify!` will expand to "concat! (Fuzz ~ Buzz)",
    // not to "FuzzBuzz"
    assert_eq!(stringify!(concat!(Fuzz ~ Buzz)), "concat! (Fuzz ~ Buzz)");
}

No runtime deps