of_function

Macro of_function 

Source
macro_rules! of_function {
    ($ident:ident) => { ... };
    ($ident:ident ::<..>) => { ... };
    ($ident:ident ::<$($arg:ty),*>) => { ... };
}
Expand description

Get the name of the given function as a &'static str.

Use a ::<..> placeholder to exclude generic parameters in the output, see examples.

ยงExamples

fn my_function() {}
fn my_generic_function<T>() {}
fn my_generic_function_2args<T, U>() {}
assert_eq!(pretty_name::of_function!(my_function), "my_function");
assert_eq!(pretty_name::of_function!(my_generic_function::<..>), "my_generic_function");
assert_eq!(pretty_name::of_function!(my_generic_function::<u32>), "my_generic_function::<u32>");
assert_eq!(pretty_name::of_function!(my_generic_function_2args::<..>), "my_generic_function_2args");
assert_eq!(pretty_name::of_function!(my_generic_function_2args::<u32, String>), "my_generic_function_2args::<u32, String>");