pub trait Compile<'a, C>: Machine<'a> {
// Required method
fn compile(
&self,
chunk_name: Option<String>,
code: C
) -> Result<Self::Function<'_>, MachineError>;
}
Expand description
Ability of Machine
s 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
.