get function name rust

To get the function name in Rust, you can use the std::any::type_name function. Here's an example:

fn get_function_name() -> &'static str {
    std::any::type_name::<Self>()
}

fn main() {
    let function_name = get_function_name();
    println!("Function name: {}", function_name);
}

This code uses the type_name function from the std::any module to get the name of the current function. The type_name function returns a &'static str, which is a string slice that lives for the entire duration of the program.

Please note that the type_name function returns the mangled name of the function, which includes additional information like the module and the type of the function. If you want to extract just the function name without any additional information, you can use string manipulation functions to extract the desired part.

I hope this helps! Let me know if you have any further questions.