pub trait EvalPolicy: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn prepare_call_args(
&self,
cx: &mut Cx,
raw: RawArgs,
demands: &[Demand],
) -> Result<PreparedArgs>;
fn force(&self, cx: &mut Cx, value: Value, demand: Demand) -> Result<Value>;
fn eval_expr(&self, cx: &mut Cx, expr: Expr) -> Result<Value>;
// Provided methods
fn allow_macro_expansion(&self, _phase: Phase) -> bool { ... }
fn resolve_unbound_symbol(
&self,
cx: &mut Cx,
symbol: Symbol,
) -> Result<Value> { ... }
fn resolve_unbound_call(
&self,
cx: &mut Cx,
operator: Symbol,
args: Vec<Expr>,
) -> Result<Value> { ... }
}Expand description
The eval-policy contract: how a call site evaluates its arguments and body.
An eval policy decides argument strategy (eager, lazy, by-need, or strict
by Demand), whether macro expansion is permitted in a given
Phase, how a value is forced to satisfy a
demand, and how a bare Expr is evaluated. The kernel ships several
reference policies (EagerPolicy, LazyPolicy, NeedPolicy,
StrictByShapePolicy, HybridPolicy, NoopEvalPolicy); libraries
may supply their own. Concrete language semantics stay out of the kernel.
Required Methods§
Sourcefn prepare_call_args(
&self,
cx: &mut Cx,
raw: RawArgs,
demands: &[Demand],
) -> Result<PreparedArgs>
fn prepare_call_args( &self, cx: &mut Cx, raw: RawArgs, demands: &[Demand], ) -> Result<PreparedArgs>
Prepares raw call arguments into PreparedArgs per the demands.
The per-position demands slice states how strongly each argument
must be forced; positions beyond its length take a policy default.
Provided Methods§
Sourcefn allow_macro_expansion(&self, _phase: Phase) -> bool
fn allow_macro_expansion(&self, _phase: Phase) -> bool
Whether macro expansion is permitted in the given Phase.
Defaults to false (no expansion in any phase).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".