How to count the length of variable name?

For instance, I want to know the length of the identifier of a macro argument, is there any way to do that?

macro_rules! sample_macro {
    ($x:ident) => {
	    println!("{:?}", /*length of x*/);
    }
}

You could use stringify and use the length of the result.

2 Likes