Immutable environment container for the current scope. Environment values can be provided by parent environments, but child functions can only mutate their environment through interior mutability.
The environment is type-indexed, and each
Scope holds 0-1 references to every
[std::any::Any] + 'static type. Access is provided through read-only references.
Aside: one interesting implication of the above is the ability to define "private scoped global values" which are private to functions which are nonetheless propagating the values with their control flow. This can be useful for runtimes to offer themselves execution-local values in functions which are invoked by external code. It can also be severely abused, like any implicit state, and should be used with caution.
The number of parent environments from which this environment descends.
child_fn with this environment as the current scope.
Returns a reference to a value in the current environment if it is present.
Returns a reference to a value in the current environment, as
Env::get does, but panics
if the value has not been set in the environment.
pub fn snapshot() -> EnvSnapshot[src]
Returns a snapshot of the current dynamic scope. Most useful for debugging the contained
Removes the provided type from the current environment for the remainder of its scope. Parent environments may still possess a reference to the value.
impl StructuralEq for Env[src]
impl StructuralPartialEq for Env[src]
impl !RefUnwindSafe for Env
impl !UnwindSafe for Env
type Owned = T
The resulting type after obtaining ownership.
fn clone_into(&self, target: &mut T)[src]
type Error = Infallible
The type returned in the event of a conversion error.