From e63189514fb477ffb58bd978e0cf63541559547f Mon Sep 17 00:00:00 2001 From: ddidderr Date: Mon, 26 Feb 2024 11:41:31 +0100 Subject: [PATCH] [feature] short name: only returns the function name --- src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 676b3e7..c29517e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,15 @@ macro_rules! function_name { }}; } +/// Only get the function name itself, not the full qualifier +#[macro_export] +macro_rules! function_name_short { + () => {{ + let name = function_name!(); + name.split("::").last().unwrap() + }}; +} + /// Like [`println!`] but also prints the current function name (including module path) and line. /// /// # Examples