caller_line

Crates.iocaller_line
lib.rscaller_line
version2.0.1
sourcesrc
created_at2024-07-03 10:59:40.320873
updated_at2024-07-04 12:26:41.663517
descriptionGet the line from which the current function was called.
homepage
repositoryhttps://github.com/amab8901/caller_line
max_upload_size
id1290428
size15,333
Iron(III) Oxide (amab8901)

documentation

https://docs.rs/caller_line

README

This crate lets you obtain the line from which the current function was called.

Example

use caller_line::caller_line;

fn call_this_function() {
    let caller_line = caller_line();

    println!("called from {caller_line}");
}

fn function_wrapper() {
    call_this_function();
}

fn main() {
    function_wrapper();
}

The above code will return the following:

called from <project path>/src/main.rs:10

...where <project path> is a placeholder for the project path, and 10 is the line number of call_this_function(); in the function body of fn function_wrapper() {...}.

Commit count: 10

cargo fmt