pub struct Parsed<T> { /* private fields */ }Expand description
Represents the parsed source code.
Implementations§
Source§impl<T> Parsed<T>
impl<T> Parsed<T>
Sourcepub fn errors(&self) -> &[ParseError]
pub fn errors(&self) -> &[ParseError]
Returns a list of syntax errors found during parsing.
Sourcepub fn unsupported_syntax_errors(&self) -> &[UnsupportedSyntaxError]
pub fn unsupported_syntax_errors(&self) -> &[UnsupportedSyntaxError]
Returns a list of version-related syntax errors found during parsing.
Sourcepub fn into_syntax(self) -> T
pub fn into_syntax(self) -> T
Consumes the Parsed output and returns the contained syntax node.
Sourcepub fn into_errors(self) -> Vec<ParseError>
pub fn into_errors(self) -> Vec<ParseError>
Consumes the Parsed output and returns a list of syntax errors found during parsing.
Sourcepub fn has_valid_syntax(&self) -> bool
pub fn has_valid_syntax(&self) -> bool
Returns true if the parsed source code is valid i.e., it has no ParseErrors.
Note that this does not include version-related UnsupportedSyntaxErrors.
See Parsed::has_no_syntax_errors for a version that takes these into account.
Sourcepub fn has_invalid_syntax(&self) -> bool
pub fn has_invalid_syntax(&self) -> bool
Returns true if the parsed source code is invalid i.e., it has ParseErrors.
Note that this does not include version-related UnsupportedSyntaxErrors.
See Parsed::has_no_syntax_errors for a version that takes these into account.
Sourcepub fn has_no_syntax_errors(&self) -> bool
pub fn has_no_syntax_errors(&self) -> bool
Returns true if the parsed source code does not contain any ParseErrors or
UnsupportedSyntaxErrors.
See Parsed::has_valid_syntax for a version specific to ParseErrors.
Sourcepub fn has_syntax_errors(&self) -> bool
pub fn has_syntax_errors(&self) -> bool
Returns true if the parsed source code contains any ParseErrors or
UnsupportedSyntaxErrors.
See Parsed::has_invalid_syntax for a version specific to ParseErrors.
Sourcepub fn as_result(&self) -> Result<&Parsed<T>, &[ParseError]>
pub fn as_result(&self) -> Result<&Parsed<T>, &[ParseError]>
Returns the Parsed output as a Result, returning Ok if it has no syntax errors,
or Err containing the first ParseError encountered.
Note that any unsupported_syntax_errors will not
cause Err to be returned.
Source§impl Parsed<Mod>
impl Parsed<Mod>
Sourcepub fn try_into_module(self) -> Option<Parsed<ModModule>>
pub fn try_into_module(self) -> Option<Parsed<ModModule>>
Attempts to convert the Parsed<Mod> into a Parsed<ModModule>.
This method checks if the syntax field of the output is a Mod::Module. If it is, the
method returns Some(Parsed<ModModule>) with the contained module. Otherwise, it
returns None.
Sourcepub fn try_into_expression(self) -> Option<Parsed<ModExpression>>
pub fn try_into_expression(self) -> Option<Parsed<ModExpression>>
Attempts to convert the Parsed<Mod> into a Parsed<ModExpression>.
This method checks if the syntax field of the output is a Mod::Expression. If it is,
the method returns Some(Parsed<ModExpression>) with the contained expression.
Otherwise, it returns None.
Trait Implementations§
Source§impl<T: GetSize> GetSize for Parsed<T>
impl<T: GetSize> GetSize for Parsed<T>
Source§fn get_heap_size(&self) -> usize
fn get_heap_size(&self) -> usize
Source§fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>(
&self,
tracker: TRACKER,
) -> (usize, TRACKER)
fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>( &self, tracker: TRACKER, ) -> (usize, TRACKER)
tracker. Read moreSource§fn get_stack_size() -> usize
fn get_stack_size() -> usize
Source§fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
tracker. Read moreimpl<T> StructuralPartialEq for Parsed<T>
Auto Trait Implementations§
impl<T> Freeze for Parsed<T>where
T: Freeze,
impl<T> RefUnwindSafe for Parsed<T>where
T: RefUnwindSafe,
impl<T> Send for Parsed<T>where
T: Send,
impl<T> Sync for Parsed<T>where
T: Sync,
impl<T> Unpin for Parsed<T>where
T: Unpin,
impl<T> UnsafeUnpin for Parsed<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Parsed<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more