Skip to content

Instantly share code, notes, and snippets.

@barseghyanartur
Created February 13, 2023 11:32
Show Gist options
  • Select an option

  • Save barseghyanartur/8b725d5d21b446edf87a7aec40e70e61 to your computer and use it in GitHub Desktop.

Select an option

Save barseghyanartur/8b725d5d21b446edf87a7aec40e70e61 to your computer and use it in GitHub Desktop.
Print function name in Rust

Print function name in Rust

Deps

[dependencies]
function_name = "0.3.0"

Code

#![allow(unused)]
use ::function_name::named;

#[named]
fn sum(a: i8, b: i8) -> i8 {
    println!(function_name!());
    a + b
}

fn main() {
    let c = sum(1, 2);
    dbg!(&c);
}

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment