Trait Compile

Source
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§

Source

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§

Source

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.

Implementations on Foreign Types§

Source§

impl Compile for &str

Source§

fn compile_with_options( self, source_manager: &dyn SourceManager, options: Options, ) -> Result<Box<Module>, Report>

Source§

impl Compile for &String

Source§

fn compile_with_options( self, source_manager: &dyn SourceManager, options: Options, ) -> Result<Box<Module>, Report>

Source§

impl Compile for &Path

Source§

fn compile_with_options( self, source_manager: &dyn SourceManager, options: Options, ) -> Result<Box<Module>, Report>

Source§

impl Compile for &[u8]

Source§

fn compile_with_options( self, source_manager: &dyn SourceManager, options: Options, ) -> Result<Box<Module>, Report>

Source§

impl Compile for Cow<'_, str>

Source§

fn compile_with_options( self, source_manager: &dyn SourceManager, options: Options, ) -> Result<Box<Module>, Report>

Source§

impl Compile for Box<str>

Source§

fn compile_with_options( self, source_manager: &dyn SourceManager, options: Options, ) -> Result<Box<Module>, Report>

Source§

impl Compile for Box<Module>

Source§

fn compile_with_options( self, _source_manager: &dyn SourceManager, options: Options, ) -> Result<Box<Module>, Report>

Source§

impl Compile for Box<[u8]>

Source§

fn compile_with_options( self, source_manager: &dyn SourceManager, options: Options, ) -> Result<Box<Module>, Report>

Source§

impl Compile for String

Source§

fn compile_with_options( self, source_manager: &dyn SourceManager, options: Options, ) -> Result<Box<Module>, Report>

Source§

impl Compile for Arc<SourceFile>

Source§

fn compile_with_options( self, source_manager: &dyn SourceManager, options: Options, ) -> Result<Box<Module>, Report>

Source§

impl Compile for Arc<Module>

Source§

fn compile_with_options( self, source_manager: &dyn SourceManager, options: Options, ) -> Result<Box<Module>, Report>

Source§

impl Compile for Vec<u8>

Source§

fn compile_with_options( self, source_manager: &dyn SourceManager, options: Options, ) -> Result<Box<Module>, Report>

Source§

impl Compile for PathBuf

Source§

fn compile_with_options( self, source_manager: &dyn SourceManager, options: Options, ) -> Result<Box<Module>, Report>

Implementors§