jdonszelmann / label

MIT License
16 stars 1 forks source link

Expose function names #1

Closed jdonszelmann closed 4 years ago

jdonszelmann commented 4 years ago

It should be possible to query the name of the function, while you are iterating over it. This will mean that the functions will need to be stored in a hashmap.

jdonszelmann commented 4 years ago

for example:

create_annotatation!(fn test() -> (););

#[test::annotate]
fn my_fn() {
    println!("Test!");
}

fn main() {
    println!("calling all 'test' label");
    // using iter you can go through all functions with this annotation.
    for name, i in test::iter_named() {
       assert_eq!(name, "my_fn");
    }
}