pub struct Location {
pub source: Source,
pub line: Option<NonZeroU32>,
pub column: Option<NonZeroU32>,
pub length: Option<NonZeroU32>,
}Expand description
Source and optional position of a configuration value.
Holds the full originating Source (name, options, resource — including any on_error
policy), so a value or error can be traced back to where and how it was declared. Positions are
1-based and stored as NonZeroU32; crate::Error boxes the Location so results stay
small. Construct via Location::in_source (the real source) or Location::at (a bare
name/resource, for synthetic origins).
Fields§
§source: Source§line: Option<NonZeroU32>§column: Option<NonZeroU32>§length: Option<NonZeroU32>UTF-8 character span length for error underlines; defaults to one caret.
Implementations§
Source§impl Location
impl Location
Sourcepub fn in_source(
source: Source,
line: Option<usize>,
column: Option<usize>,
length: Option<usize>,
) -> Self
pub fn in_source( source: Source, line: Option<usize>, column: Option<usize>, length: Option<usize>, ) -> Self
Build a location from the full originating Source.
Sourcepub fn at(
source_name: &str,
resource: &str,
line: Option<usize>,
column: Option<usize>,
length: Option<usize>,
) -> Self
pub fn at( source_name: &str, resource: &str, line: Option<usize>, column: Option<usize>, length: Option<usize>, ) -> Self
Build a location from a bare source name and resource (a synthetic Source with no
options), for origins that do not come from parsing a real source string.
Sourcepub fn source_name(&self) -> &str
pub fn source_name(&self) -> &str
The originating source’s name (loader kind).