Crate code_location
source · [−]Expand description
A library to automatically acquire a code location in a rust source code file.
UNMAINTAINED
This library is no longer maintained.
Although it does work fine, I recommend using [std::panic::Location
] instead.
Description
The library provides the code_location!()
macro.
The macro expands to the CodeLocation
struct
by combining the standard file!()
, line!()
and column!()
macros.
Examples
use code_location::code_location;
println!("I am printing from {}", code_location!());
assert_eq!(code_location!().to_string(), "src/lib.rs:7:12");
use code_location::{code_location, CodeLocation};
let code_location: CodeLocation = code_location!();
assert_eq!(code_location.file, "src/lib.rs");
assert_eq!(code_location.line, 6);
assert_eq!(code_location.column, 35);
serde
serialization and deserialization support
serde
support can be enabled with the "serde"
feature.
#![no_std]
code_location
does not depend on the standard library.
Macros
Expands to the CodeLocation
on which it was invoked.
Structs
A CodeLocation type to represent a certain point in a source code text file.