pub trait Parse: Sized {
// Required method
fn parse_with_options(
self,
source_manager: &dyn SourceManager,
options: ParseOptions,
) -> Result<Box<Module>, Report>;
// Provided method
fn parse(
self,
source_manager: &dyn SourceManager,
) -> Result<Box<Module>, Report> { ... }
}
Expand description
This trait is meant to be implemented by any type that can be parsed to a Module, to allow methods which expect a Module to accept things like:
- A Module which was previously parsed or deserialized
- A string representing the source code of a Module.
- A path to a file containing the source code of a Module.
- A vector of crate::ast::Forms comprising the contents of a Module.
Required Methods§
Sourcefn parse_with_options(
self,
source_manager: &dyn SourceManager,
options: ParseOptions,
) -> Result<Box<Module>, Report>
fn parse_with_options( self, source_manager: &dyn SourceManager, options: ParseOptions, ) -> Result<Box<Module>, Report>
Parse (or convert) self
into a Module using the provided options
.
Returns a Report if parsing fails due to a parsing or semantic analysis error, or if the module provided is of the wrong kind (e.g. we expected a library module but got an executable module).
See the documentation for ParseOptions
to see how parsing can be configured.
Provided Methods§
Sourcefn parse(
self,
source_manager: &dyn SourceManager,
) -> Result<Box<Module>, Report>
fn parse( self, source_manager: &dyn SourceManager, ) -> Result<Box<Module>, Report>
Parse (or convert) self
into an executable Module.
See Parse::parse_with_options
for more details.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.