[][src]Struct topo::Env

pub struct Env { /* fields omitted */ }

Immutable environment container for the current (sub)topology. Environment values can be provided by parent topological invocations (currently just with call and root), but child functions can only mutate their environment through interior mutability.

The environment is type-indexed/type-directed, and each Env holds 0-1 instances of 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.

Methods

impl Env[src]

pub fn get<E>() -> Option<impl Deref<Target = E> + 'static> where
    E: Any + 'static, 
[src]

Returns a reference to a value in the current environment if it has been added to the environment by parent/enclosing call invocations.

pub fn expect<E>() -> impl Deref<Target = E> + 'static where
    E: Any + 'static, 
[src]

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.

Trait Implementations

impl Default for Env[src]

impl Clone for Env[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Env[src]

Auto Trait Implementations

impl Unpin for Env

impl !Send for Env

impl !Sync for Env

impl !RefUnwindSafe for Env

impl !UnwindSafe for Env

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T[src]