pub struct Span {
pub start: Marker,
pub end: Marker,
pub indent: Option<usize>,
pub tag_start: Option<Marker>,
}Expand description
A range of locations in a YAML document.
Fields§
§start: MarkerThe start (inclusive) of the range.
end: MarkerThe end (exclusive) of the range.
indent: Option<usize>Optional indentation hint associated with this span.
This is only meaningful for certain parser-emitted events (notably: block mapping keys).
When indentation is not meaningful or cannot be provided, it must be None.
tag_start: Option<Marker>Optional source marker for the explicit tag token attached to this node.
This is only meaningful for parser-emitted node events that carry a resolved tag, such as
Event::Scalar,
Event::SequenceStart, or
Event::MappingStart. The normal Span::start and
Span::end continue to cover the node value or collection; tag_start points to the
tag token when that token appears at a different source location.
Implementations§
Source§impl Span
impl Span
Sourcepub fn empty(mark: Marker) -> Span
pub fn empty(mark: Marker) -> Span
Create an empty Span at a given location.
An empty span doesn’t contain any characters, but its position may still be meaningful.
For example, for an indented sequence SequenceEnd has a location but an empty span.
Sourcepub fn with_indent(self, indent: Option<usize>) -> Span
pub fn with_indent(self, indent: Option<usize>) -> Span
Return a copy of this Span with the given indentation hint.
Sourcepub fn with_tag_start(self, tag_start: Option<Marker>) -> Span
pub fn with_tag_start(self, tag_start: Option<Marker>) -> Span
Return a copy of this Span with the given explicit tag-token start marker.
Sourcepub fn tag_start(&self) -> Option<Marker>
pub fn tag_start(&self) -> Option<Marker>
Return the source marker of the explicit tag token attached to this node, if any.
The regular span still covers the node value or collection. This accessor is useful for diagnostics that should point at the tag itself, especially when a tagged block collection begins on a later line than the tag token.
Sourcepub fn byte_range(&self) -> Option<Range<usize>>
pub fn byte_range(&self) -> Option<Range<usize>>
Return the byte range of the span, if available.