News for hackers. Stuff that matters.
Re:Implementing a Type-safe printf in Rust by skohan on Friday August 14, 2020 @04:20AM (#24155279)
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.
Re:Implementing a Type-safe printf in Rust by stjepang on Friday August 14, 2020 @04:38AM (#24155406)
Re:Implementing a Type-safe printf in Rust by skohan on Saturday August 15, 2020 @05:31AM (#24167441)
Neat. 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.
Re:Implementing a Type-safe printf in Rust by stjepang on Saturday August 15, 2020 @05:36AM (#24167480)
Right, there is a way - to escape braces and print "text {value}" rather than the actual value, you'd use "text {{value}}"
Re:Implementing a Type-safe printf in Rust by Groxx on Saturday August 15, 2020 @01:35AM (#24166242)
Since 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).