caller_line 2.0.1

Get the line from which the current function was called.
Documentation
  • Coverage
  • 0%
    0 out of 3 items documented0 out of 1 items with examples
  • Size
  • Source code size: 15.33 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 352.49 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • amab8901/caller_line
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • amab8901

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() {...}.