SilentByte / nameof

Provides a Rust macro to determine the string name of a binding, type, or function.
https://crates.io/crates/nameof
MIT License
37 stars 3 forks source link

Add associated constants support #3

Closed A1-Triard closed 4 years ago

A1-Triard commented 4 years ago

For example, the associated constants can be generated by widely used bitflags crate:

bitflags! {
    pub struct SomeFlags: u64 {
        const PERSISTENT = 0x40000000000;
        const BLOCKED = 0x200000000000;
        const DELETED = 0x2000000000;
    }
}

fn main() {
    println!("There is some flag with '{}' name.", name_of!(const PERSISTENT in SomeFlags));
}
SilentByte commented 4 years ago

Looks good, thanks! I merged it and bumped up the version on crates.io.

Cheers