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.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.