pub struct Trivia { /* private fields */ }Expand description
Whitespace or a comment retained in the raw token stream.
Implementations§
Source§impl Trivia
impl Trivia
Sourcepub fn from_span(kind: TriviaKind, span: Span) -> Self
pub fn from_span(kind: TriviaKind, span: Span) -> Self
Creates trivia whose spelling is already available through its span.
§Panics
Panics when span has no source backing.
Sourcepub fn new(kind: TriviaKind, text: impl Into<Arc<str>>, span: Span) -> Self
pub fn new(kind: TriviaKind, text: impl Into<Arc<str>>, span: Span) -> Self
Creates trivia from its category, exact text, and span.
Sourcepub fn kind(&self) -> TriviaKind
pub fn kind(&self) -> TriviaKind
Returns the trivia category.
Sourcepub fn text(&self) -> &str
pub fn text(&self) -> &str
Returns the trivia exactly as it appeared in source.
§Panics
Panics if this token’s invariant that its span is source-backed was violated.
Sourcepub fn contains_line_break(&self) -> bool
pub fn contains_line_break(&self) -> bool
Reports whether this trivia contains a line feed.
Trait Implementations§
impl Eq for Trivia
Source§impl Lex for Trivia
impl Lex for Trivia
Source§fn to_tokens(&self, output: &mut TokenStream)
fn to_tokens(&self, output: &mut TokenStream)
Appends this value’s token trees to
output.Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Emits this value into a fresh token stream.
Source§impl Parse for Trivia
impl Parse for Trivia
Source§fn parse(input: &mut ParseStream) -> Result<Self, TokenParseError>
fn parse(input: &mut ParseStream) -> Result<Self, TokenParseError>
Consumes this value from
input. Read moreimpl StructuralPartialEq for Trivia
Auto Trait Implementations§
impl Freeze for Trivia
impl RefUnwindSafe for Trivia
impl Send for Trivia
impl Sync for Trivia
impl Unpin for Trivia
impl UnsafeUnpin for Trivia
impl UnwindSafe for Trivia
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