pub trait Compile: Sized {
// Required method
fn compile_with_options(
self,
source_manager: &dyn SourceManager,
options: Options,
) -> Result<Box<Module>, Report>;
// Provided method
fn compile(
self,
source_manager: &dyn SourceManager,
) -> Result<Box<Module>, Report> { ... }
}Expand description
This trait is meant to be implemented by any type that can be compiled 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 compile_with_options(
self,
source_manager: &dyn SourceManager,
options: Options,
) -> Result<Box<Module>, Report>
fn compile_with_options( self, source_manager: &dyn SourceManager, options: Options, ) -> Result<Box<Module>, Report>
Compile (or convert) self into a Module using the provided options.
Returns a Report if compilation 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 Options to see how compilation can be configured.
Provided Methods§
Sourcefn compile(
self,
source_manager: &dyn SourceManager,
) -> Result<Box<Module>, Report>
fn compile( self, source_manager: &dyn SourceManager, ) -> Result<Box<Module>, Report>
Compile (or convert) self into an executable Module.
See Compile::compile_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.