pub struct Token<'a> {
pub kind: TokenKind,
pub text: Cow<'a, str>,
pub space_diff: usize,
}
Expand description
Represents a single meaningful substring part in an Interact string expression.
Fields§
§kind: TokenKind
Token kind
text: Cow<'a, str>
Token text
space_diff: usize
Amount of whitespace from the previous token
Implementations§
Source§impl<'a> Token<'a>
impl<'a> Token<'a>
pub fn new_owned(s: String) -> Self
pub fn new_borrowed(kind: TokenKind, s: &'static str) -> Self
pub fn clone_owned(&self) -> Token<'static>
Sourcepub fn similar(&self, token: &Token<'_>) -> bool
pub fn similar(&self, token: &Token<'_>) -> bool
Returns whether two tokens are idential with whitespace removed.
Sourcepub fn is_prefix_of(&self, token: &Token<'_>) -> bool
pub fn is_prefix_of(&self, token: &Token<'_>) -> bool
Returns whether one token is a prefix or another.
Sourcepub fn space_suffix(&self) -> usize
pub fn space_suffix(&self) -> usize
Return the amount of space following the text of the token.
Trait Implementations§
impl<'a> Eq for Token<'a>
impl<'a> StructuralPartialEq for Token<'a>
Auto Trait Implementations§
impl<'a> Freeze for Token<'a>
impl<'a> RefUnwindSafe for Token<'a>
impl<'a> Send for Token<'a>
impl<'a> Sync for Token<'a>
impl<'a> Unpin for Token<'a>
impl<'a> UnwindSafe for Token<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more