pub trait EvalContextFamily: 'static {
type Context<'a>;
}Expand description
A “family” of evaluation context types, parameterized by lifetime.
This trait uses Generic Associated Types (GATs) to separate the context family (known at parse time, carries no lifetime) from the concrete context type (instantiated with a lifetime at execution time).
§Why a family?
The parser is long-lived and created once, but contexts are short-lived and often
borrow data. We can’t write Parser<MyContext<'a>> because 'a doesn’t exist
when the parser is created. Instead, the parser stores the family F, and
F::Context<'a> is only materialized when execute is called.
§Example
ⓘ
struct SpanFamily;
impl EvalContextFamily for SpanFamily {
type Context<'a> = SpanContext<'a>;
}
struct SpanContext<'a> {
span: &'a mut Span,
resource: &'a Resource,
}Required Associated Types§
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.