pub trait Compile<'a, C>: Machine<'a> {
    fn compile(
        &self,
        chunk_name: Option<String>,
        code: C
    ) -> Result<Self::Function<'_>, MachineError>; }
Expand description

Ability of Machines to compile provided code (of a certain type, e.g. &str or String)

Owned vs borrowed code

Implementations should provide an implementation both for the owned and the borrowed variant of the type representing the code (e.g. String and &str, or Vec<u8> and &[u8]). The chunk_name is always passed as owned String, as it will usually be stored in the returned Function.

Example

See Machine.

Required methods

Compiles code, returns the compiled function or a compilation error

chunk_name is an optional chunk name for diagnostic output.

Implementors