Function puffin::shorten_rust_function_name

source ·
pub fn shorten_rust_function_name(name: &str) -> String
Expand description

Shorten a rust function name by removing the leading parts of module paths.

While the puffin profiling macros takes care of this internally, this function can be useful for those registering custom scopes for rust functions.

§Example

use puffin::shorten_rust_function_name;

assert_eq!(shorten_rust_function_name("foo::bar::baz::function_name"), "baz::function_name");
assert_eq!(shorten_rust_function_name("<some::ConcreteType as some::Trait>::function_name"), "<ConcreteType as Trait>::function_name");