pub trait Environment {
// Required methods
fn today(&self) -> String;
fn now(&self) -> String;
// Provided methods
fn secondary_instance(&self, _id: &str) -> Option<&Instance> { ... }
fn choice_label(&self, _value: &str, _question_path: &str) -> Option<String> { ... }
}Expand description
Anything the evaluator needs that the instance alone cannot answer:
secondary instances for instance(), and the values today() and
now() should return.
Time is injected rather than read from the clock so that evaluating the same form twice gives the same answer — a test that drifts at midnight is worse than no test.
Required Methods§
Provided Methods§
fn secondary_instance(&self, _id: &str) -> Option<&Instance>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".