declaration_site 0.2.0

Iterate through the debug info associated with currently loaded functions
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::time::Instant;

use declaration_site::declaration_of;

fn main() {
    let now = Instant::now();
    let declaration =
        declaration_of(&function_to_find).expect("Should have gotten declaration site");
    println!(
        "Found {declaration} in {elapsed:?}",
        elapsed = now.elapsed()
    );
    // Ensure that the function is linked
    function_to_find();
}

#[inline(never)]
fn function_to_find() {}