pub struct Token<'a, CustomTy>where
CustomTy: Clone,{
pub span: &'a str,
pub start: usize,
pub kind: TokenKind<'a, CustomTy>,
}Expand description
A parsed token, as returned by BBParser::next.
Fields§
§span: &'a str§start: usize§kind: TokenKind<'a, CustomTy>Implementations§
source§impl<'a, CustomTy> Token<'a, CustomTy>where
CustomTy: Clone,
impl<'a, CustomTy> Token<'a, CustomTy>where
CustomTy: Clone,
Properties of a Token like its arguments or kind.
sourcepub fn is_open(&self, tag_name: &str) -> bool
pub fn is_open(&self, tag_name: &str) -> bool
Whether or not this tag is an open tag of the given type.
§Remarks
This ignores the arguments of the tag, use Token::is_open_argless to ensure they’re empty.
sourcepub fn is_open_argless(&self, tag_name: &str) -> bool
pub fn is_open_argless(&self, tag_name: &str) -> bool
Whether or not this tag is an open tag of the given type, without arguments.
sourcepub fn is_close(&self, tag_name: &str) -> bool
pub fn is_close(&self, tag_name: &str) -> bool
Whether or not this tag is a close tag of the given type.
§Remarks
This ignores the arguments of the tag, use Token::is_close_argless to ensure they’re empty.
sourcepub fn is_close_argless(&self, tag_name: &str) -> bool
pub fn is_close_argless(&self, tag_name: &str) -> bool
Whether or not this tag is a close tag of the given type, without arguments.
sourcepub fn is_standalone(&self, tag_name: &str) -> bool
pub fn is_standalone(&self, tag_name: &str) -> bool
Whether or not this tag is a standalone tag of the given type.
§Remarks
This ignores the arguments of the tag, use Token::is_standalone_argless to ensure they’re empty.
sourcepub fn is_standalone_argless(&self, tag_name: &str) -> bool
pub fn is_standalone_argless(&self, tag_name: &str) -> bool
Whether or not this tag is a standalone tag of the given type, without arguments.
source§impl<'a, CustomTy> Token<'a, CustomTy>where
CustomTy: Clone,
impl<'a, CustomTy> Token<'a, CustomTy>where
CustomTy: Clone,
Token “rewriters”, which modify the token in-place.
sourcepub fn rewrite_as_text(&mut self)
pub fn rewrite_as_text(&mut self)
Rewrite the token as text, in place, without altering any other properties.
sourcepub fn rewrite_with_opening_tag(&mut self, idx: usize)
pub fn rewrite_with_opening_tag(&mut self, idx: usize)
Mark the index of a close tag’s opening tag within it, without altering anything else.
§Panics
Panics if the tag is not a closing tag.