pub struct YoshiLocation {
pub file: &'static str,
pub line: u32,
pub column: u32,
}serde only.Expand description
Enhanced source code location with const evaluation.
YoshiLocation captures the file name, line number, and column number
where an error or context was created. This is crucial for debugging
and pinpointing the exact origin of an issue in the source code.
Fields§
§file: &'static strFile path with const string optimization.
A static string slice representing the full path to the source file.
line: u32Line number.
The line number in the source file.
column: u32Column number.
The column number within the line in the source file.
Implementations§
Source§impl YoshiLocation
impl YoshiLocation
Sourcepub const fn new(file: &'static str, line: u32, column: u32) -> Self
pub const fn new(file: &'static str, line: u32, column: u32) -> Self
Creates a new location with const evaluation where possible.
This constructor is typically used by the yoshi_location! macro
to capture source locations at compile time.
§Arguments
file- The static string slice representing the file path.line- The line number.column- The column number.
§Returns
A new YoshiLocation instance.
§Examples
const MY_LOCATION: YoshiLocation = YoshiLocation::new("src/main.rs", 10, 5);
assert_eq!(MY_LOCATION.file, "src/main.rs");
assert_eq!(MY_LOCATION.line, 10);
assert_eq!(MY_LOCATION.column, 5);Sourcepub fn filename(&self) -> &str
pub fn filename(&self) -> &str
Gets just the filename without path for compact display.
This utility method extracts the base filename from the full file path, making it more convenient for display in logs or error messages.
§Returns
A string slice containing only the filename.
§Examples
let loc = YoshiLocation::new("/home/user/project/src/lib.rs", 1, 1);
assert_eq!(loc.filename(), "lib.rs");
let loc_windows = YoshiLocation::new("C:\\Users\\dev\\main.rs", 1, 1);
// On Windows, filename() should work with both path separators
assert!(loc_windows.filename().ends_with("main.rs"));Trait Implementations§
Source§impl Clone for YoshiLocation
impl Clone for YoshiLocation
Source§fn clone(&self) -> YoshiLocation
fn clone(&self) -> YoshiLocation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more