pub enum GraphQLTriviaToken<'src> {
Comment {
value: Cow<'src, str>,
span: ByteSpan,
},
Comma {
span: ByteSpan,
},
Whitespace {
value: Cow<'src, str>,
span: ByteSpan,
},
}Expand description
A “trivia token” is a token that doesn’t affect parsing but is still preserved (e.g. for tooling use).
Trivia includes comments, commas, and whitespace, which are attached to the following token as “preceding trivia”. This allows formatters and linters to preserve these elements without the parser needing to handle them explicitly.
§Lifetime Parameter
The 'src lifetime enables zero-copy lexing for comment and whitespace
values: StrGraphQLTokenSource can borrow text directly from the source.
Variants§
Comment
A GraphQL comment, which starts with # and extends to the end of the
line.
Fields
Comma
A comma separator. In GraphQL, commas are optional and treated as whitespace, but we preserve them as trivia.
Whitespace
A run of whitespace characters (spaces, tabs, newlines, BOM).
In GraphQL, whitespace is insignificant (it doesn’t affect parsing),
but preserving it as trivia enables lossless source reconstruction.
Each Whitespace trivia token captures a contiguous run of whitespace
exactly as it appears in the source.
Trait Implementations§
Source§impl<'src> Clone for GraphQLTriviaToken<'src>
impl<'src> Clone for GraphQLTriviaToken<'src>
Source§fn clone(&self) -> GraphQLTriviaToken<'src>
fn clone(&self) -> GraphQLTriviaToken<'src>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more