Struct apollo_parser::SyntaxTree
source · [−]pub struct SyntaxTree { /* private fields */ }
Expand description
An AST generated by the parser. Consists of a syntax tree and a Vec<Error>
if any.
Example
Given a syntactically incorrect token uasdf21230jkdw
which cannot be part
of any of GraphQL definitions and a syntactically correct SelectionSet, we
are able to see both the AST for the SelectionSet and the error with an
incorrect token.
use apollo_parser::Parser;
let schema = r#"
uasdf21230jkdw
{
pet
faveSnack
}
"#;
let parser = Parser::new(schema);
let ast = parser.parse();
// The Vec<Error> that's part of the SyntaxTree struct.
assert_eq!(ast.errors().len(), 1);
// The AST with Document as its root node.
let doc = ast.document();
let nodes: Vec<_> = doc.definitions().into_iter().collect();
assert_eq!(nodes.len(), 1);
Implementations
sourceimpl SyntaxTree
impl SyntaxTree
sourcepub fn recursion_limit(&self) -> LimitTracker
pub fn recursion_limit(&self) -> LimitTracker
Get the syntax tree’s recursion limit.
Trait Implementations
sourceimpl Clone for SyntaxTree
impl Clone for SyntaxTree
sourcefn clone(&self) -> SyntaxTree
fn clone(&self) -> SyntaxTree
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for SyntaxTree
impl Debug for SyntaxTree
sourceimpl PartialEq<SyntaxTree> for SyntaxTree
impl PartialEq<SyntaxTree> for SyntaxTree
sourcefn eq(&self, other: &SyntaxTree) -> bool
fn eq(&self, other: &SyntaxTree) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SyntaxTree) -> bool
fn ne(&self, other: &SyntaxTree) -> bool
This method tests for !=
.
impl Eq for SyntaxTree
impl StructuralEq for SyntaxTree
impl StructuralPartialEq for SyntaxTree
Auto Trait Implementations
impl !RefUnwindSafe for SyntaxTree
impl !Send for SyntaxTree
impl !Sync for SyntaxTree
impl Unpin for SyntaxTree
impl !UnwindSafe for SyntaxTree
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more