#[non_exhaustive]pub struct Position {
pub line: u32,
pub column: u32,
pub file: Option<Arc<Vec<String>>>,
}Expand description
A Position represents a human-readable position in a document — one ASG
locationBoundary. For byte offsets, use Location.absolute_start /
Location.absolute_end.
Equality and hashing cover all three fields, file included: two positions at
the same line/column but reached through different include:: chains — or one from
the primary input (file: None) versus one from an included file — are not equal.
This is deliberate: a line/column is only a unique location together with its file.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.line: u32The line number of the position (1-indexed).
column: u32The column number of the position (1-indexed, counted as Unicode scalar values).
file: Option<Arc<Vec<String>>>The include:: chain this position’s content came through, outermost target
first and the file directly containing the content last — each element the
include target as written in its directive (e.g. ["a.adoc", "b.adoc"] for
content in b.adoc included by a.adoc). None for content from the primary
input, which the ASG omits. Shared (Arc) across all positions reached through
the same chain, so the field stays a thin 8-byte pointer.
Implementations§
Source§impl Position
impl Position
Sourcepub fn new(line: u32, column: u32) -> Self
pub fn new(line: u32, column: u32) -> Self
A position at line/column with no originating file (primary input).
Sourcepub fn from_line_col(line: usize, column: usize) -> Self
pub fn from_line_col(line: usize, column: usize) -> Self
A position from usize line/column, saturating at u32::MAX (neither can
realistically exceed it). For callers that already hold u32 — the hot parse
and diagnostic paths — prefer the lossless new. The named
arguments here guard against accidentally transposing line and column at the
many usize-scanning call sites (preprocessor line counters, byte indices).