pub struct SourceLocation {
pub crate_name: &'static str,
pub crate_version: &'static str,
pub filename: String,
pub line_number: u32,
pub column_number: u32,
}Expand description
Captures a source code location (file, line, column).
Automatically captured via #[track_caller] when creating error frames.
Can format the location as a clickable terminal hyperlink for supported IDEs.
Fields§
§crate_name: &'static strName of the crate where the location was captured.
crate_version: &'static strVersion of the crate where the location was captured.
filename: StringFile path (can be absolute or relative).
line_number: u32Line number in the source file.
column_number: u32Column number in the source file.
Implementations§
Source§impl SourceLocation
impl SourceLocation
Sourcepub fn from_caller_location() -> Self
pub fn from_caller_location() -> Self
Capture the current caller’s source location via #[track_caller].
Sourcepub fn from_panic_location(location: &Location<'_>) -> Self
pub fn from_panic_location(location: &Location<'_>) -> Self
Create from a panic hook’s Location.
Sourcepub fn from_metadata(metadata: &Metadata<'_>) -> Self
pub fn from_metadata(metadata: &Metadata<'_>) -> Self
Create from tracing span metadata.
Sourcepub fn display_location(
&self,
overwrite_link_fmt: Option<LinkDebugIde>,
) -> String
pub fn display_location( &self, overwrite_link_fmt: Option<LinkDebugIde>, ) -> String
Format the location as a string, optionally with a clickable terminal hyperlink.
Trait Implementations§
Source§impl Clone for SourceLocation
impl Clone for SourceLocation
Source§fn clone(&self) -> SourceLocation
fn clone(&self) -> SourceLocation
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SourceLocation
impl Debug for SourceLocation
Auto Trait Implementations§
impl Freeze for SourceLocation
impl RefUnwindSafe for SourceLocation
impl Send for SourceLocation
impl Sync for SourceLocation
impl Unpin for SourceLocation
impl UnwindSafe for SourceLocation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more