Is it possible to generate a symbol or identifier in a Rust macro from a string? Or to perform string-like operations on a identifier?
I wanted to generate a method given a symbol, but need to downcase it to obtain the method name.
get!(B);
// should expand to
fn b() -> B {
// method body
}
It's easy to get close...
macro_rules! get {
($kind:ident, $method:ident)
=>
{
fn $method() -> $kind {
// method body
}
}
}
get!(B, b)
But dissatisfying.