[−][src]Struct topo::Env
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]
E: Any + 'static,
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]
E: Any + 'static,
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(&self) -> 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]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,