pub struct Tag {
pub anchor: Option<AnchorLocation>,
pub span: Span,
}
Expand description
The set of metadata that can be associated with a value
Fields§
§anchor: Option<AnchorLocation>
The original source for this value
span: Span
The span in the source text for the command that created this value
Implementations§
Source§impl Tag
impl Tag
Sourcepub fn new(anchor: Option<AnchorLocation>, span: Span) -> Self
pub fn new(anchor: Option<AnchorLocation>, span: Span) -> Self
Constructs a new Tag
.
Source§impl Tag
impl Tag
Sourcepub fn default() -> Self
pub fn default() -> Self
Creates a default Tag' with unknown
Spanposition and no
AnchorLocation`
pub fn anchored(self, anchor: Option<AnchorLocation>) -> Tag
Sourcepub fn unknown_anchor(span: Span) -> Tag
pub fn unknown_anchor(span: Span) -> Tag
Creates a Tag
from the given Span
with no AnchorLocation
Sourcepub fn for_char(pos: usize, anchor: AnchorLocation) -> Tag
pub fn for_char(pos: usize, anchor: AnchorLocation) -> Tag
Creates a Tag
from the given AnchorLocation
for a span with a length of 1.
Sourcepub fn unknown_span(anchor: AnchorLocation) -> Tag
pub fn unknown_span(anchor: AnchorLocation) -> Tag
Creates a Tag
for the given AnchorLocation
with unknown Span
position.
Sourcepub fn anchor(&self) -> Option<AnchorLocation>
pub fn anchor(&self) -> Option<AnchorLocation>
Returns the AnchorLocation
of the current Tag
Sourcepub fn until(&self, other: impl Into<Tag>) -> Tag
pub fn until(&self, other: impl Into<Tag>) -> Tag
Both Tags must share the same AnchorLocation
.
Sourcepub fn until_option(&self, other: Option<impl Into<Tag>>) -> Tag
pub fn until_option(&self, other: Option<impl Into<Tag>>) -> Tag
Merges the current Tag
with the given optional Tag
.
Both Tag
s must share the same AnchorLocation
.
The resulting Tag
will have a Span
that starts from the current Tag
and ends at Span
of the given Tag
.
Should the None
variant be passed in, a new Tag
with the same Span
and AnchorLocation
will be returned.