3 releases (stable)
2.0.1 | Jul 4, 2024 |
---|---|
1.0.1 | Jul 3, 2024 |
0.0.1 | Jul 3, 2024 |
#4 in #caller
68 downloads per month
7KB
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() {...}
.
Dependencies
~2.4–3.5MB
~71K SLoC