i'm writing a custom string type, and i have a declarative macro that can be used to construct it from bytestring literals, like my_str!(b"string data")
. i want this macro to be able to also accept plain string literals, such as my_str!("string data")
, but i'm not sure what the best way to do that is.
using a simple procedural macro that converts any string literal into a bytestring literal should work, and it would be quite handy if someone already has written a crate that does this, but i'm not sure..
the other option is to make the underlying constructor function generic over AsRef<[u8]>
, allowing it to accept str
arguments, unfortunatly that doesn't work, since i need the argument to be converted into an array with known length, not a DST.