Feature gate: #![feature(proc_macro_value)]
This feature provides methods on proc_macro::Literal to get their unescaped string equivalent.
Public API
For now, the only choice to get these values is to either copy-paste rustc's source code or use syn which has more or less the same code to achieve the same result.
After this change, one will be able to do:
// The one provided by `proc-macro`.
let literal_string = Literal::String { .. };
let unescaped_string_literal = literal_string.str_value().expect("failed to unescape");
Steps / History
Unresolved Questions
Feature gate:
#![feature(proc_macro_value)]This feature provides methods on
proc_macro::Literalto get their unescaped string equivalent.Public API
For now, the only choice to get these values is to either copy-paste rustc's source code or use
synwhich has more or less the same code to achieve the same result.After this change, one will be able to do:
Steps / History
Unresolved Questions
_valueAPI for number literals in proc-macro #154608 (comment)).Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩