Sometimes I get tired typing in to_string
, especially in test cases so I wrote this macro.
examples/macro-to-string/src/main.rs
macro_rules! s(($result:expr) => ($result.to_string()));
fn main() {
let name = s!("Foo Bar");
println!("Hello, {}!", name);
}
I am a bit ambivalent as I don't like one-letter variables or functions name, but I want this to be short.
An besides I can search for s!
if I am looking for all the uses.