Rotate a number into a string literal similar to stringify! ()

I am trying to write a macro that turns a number into a byte string literal, just as a macro stringify!can turn its argument into &str.

More specifically, how would I write this:

byte_stringify!(10) -> b"10"

I will use this to create a large number of structures const, so I cannot rely on a method call on str.

More ambitious, I'm actually trying to add and add text before turning the argument into a byte string:

make_arg!(10) -> b"x10y"

Update:

Where did the old macro go bytes!? I think I want: bytes!(stringify!(10))

+4
source share
1 answer

; , , .

Rust Book, , Rust; -, , .

.

+5

All Articles