pub struct Location<'a> { /* private fields */ }
Expand description
A struct containing information about the location of a panic.
This structure is created by PanicHookInfo::location()
and PanicInfo::location()
.
§Examples
ⓘ
use std::panic;
panic::set_hook(Box::new(|panic_info| {
if let Some(location) = panic_info.location() {
println!("panic occurred in file '{}' at line {}", location.file(), location.line());
} else {
println!("panic occurred but can't get location information...");
}
}));
panic!("Normal panic");
§Comparisons
Comparisons for equality and ordering are made in file, line, then column priority.
Files are compared as strings, not Path
, which could be unexpected.
See