4 ms·
One feature I really miss in Rust is being able to insert variables in place in strings, like you have in Swift, or JS template literals.
by skohan 6y ago
One feature I really miss in Rust is being able to insert variables in place in strings, like you have in Swift, or JS template literals.
- stjepang 6y agoThis is being worked on: https://github.com/rust-lang/rust/issues/67984 https://github.com/rust-lang/rust/issues/67984
- skohan 6y agoNeat. It's interesting that they've chosen just plain braces to denote the argument insertion; i.e: "text {value}" rather than something like "text ${value}" which seems to be what most languages use. I guess there must be a way to escape it if you just want braces in your string.
- stjepang 6y agoRight, there is a way - to escape braces and print "text {value}" rather than the actual value, you'd use "text {{value}}"
- Groxx 6y agoSince procedural macros are non-hygenic, seems like this shouldn't be too hard? Though it may not be in the stdlib (yet?) for Reasons (e.g. exact syntax, edge cases).