Re:Announcing Rust 1.30
by steveklabnik on Thursday October 25, 2018 @04:55PM
(#18304514)
The only reason to define it as `r#something` is if something is a keyword, and so regular-old `something` doesn't work. But if you happened to do it anyway, then yeah: https://play.rust-lang.org/?version=beta&mode=debug&edition=...
But yes, the `r#` isn't part of the name; if I define a Rust 2015 function as `fn async()`, in 2015 i can call it as just regular async() in 2015 code, and only need r#async() in Rust 2018 code.
And yeah, this is useful for codegen tools as well.
Besides the backward compatibility reason they might also be good for codegen tools. I encountered the situation multiple times that some identifier was used in an IDL (e.g. Thrift, Protobuf, etc) that then got exported into a keyword in a target language which prevented it from compiling. To word around that sometimes the IDL definition needed to be changed, which wasn't ideal. By generating only raw identifiers this can be avoided.