| Crates.io | caller_line |
| lib.rs | caller_line |
| version | 2.0.1 |
| created_at | 2024-07-03 10:59:40.320873+00 |
| updated_at | 2024-07-04 12:26:41.663517+00 |
| description | Get the line from which the current function was called. |
| homepage | |
| repository | https://github.com/amab8901/caller_line |
| max_upload_size | |
| id | 1290428 |
| size | 15,333 |
This crate lets you obtain the line from which the current function was called.
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() {...}.