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
sourceimpl 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
.
sourceimpl 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.
pub fn slice<'a>(&self, source: &'a str) -> &'a str
pub fn string(&self, source: &str) -> String
pub fn tagged_slice<'a>(&self, source: &'a str) -> Tagged<&'a str>
pub fn tagged_string(&self, source: &str) -> Tagged<String>
pub fn anchor_name(&self) -> Option<String>
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Tag
impl<'de> Deserialize<'de> for Tag
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for Tag
impl Ord for Tag
sourceimpl PartialOrd<Tag> for Tag
impl PartialOrd<Tag> for Tag
sourcefn partial_cmp(&self, other: &Tag) -> Option<Ordering>
fn partial_cmp(&self, other: &Tag) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for Tag
impl StructuralEq for Tag
impl StructuralPartialEq for Tag
Auto Trait Implementations
impl RefUnwindSafe for Tag
impl Send for Tag
impl Sync for Tag
impl Unpin for Tag
impl UnwindSafe for Tag
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more