Turn a number into a byte string literal, similar to stringify!()

Viewed 327

I'm trying to write a macro that would turn a number into a byte string literal, similar to how the stringify! macro can turn its argument into a &str.

More concretely, how would I write this:

byte_stringify!(10) -> b"10"

I will be using this to create a large number of const structs, so I can't really rely on calling a method on str.

More ambitiously, I'm actually trying to prepend and append some text before turning the argument into a byte string:

make_arg!(10) -> b"x10y"

Update:

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

1 Answers
Related