Is there anyway to pre-process a string compile time. For example, It would be really useful to replace a certain character compile time.
// this
println!("Some test string".replace(' ', '-'));
//would compile as this
println!("Some-test-string");
// giving this
// output
//
// Some-test-string
//
The println! macro requires a string literal (not even a const will work), so the replacement would need to be done by another macro.
The standard library doesn’t have a macro for replacing characters in string literals, and I haven’t found any external libraries that do it either, but you could write your own procedural macro.