[][src]Function illicit::expect

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

Returns a reference to a value in the current environment, as get does, but panics if the value has not been set.

The panic message includes the stack of current Layers and their contents.

Examples

let msg = "hello!";
illicit::Layer::new().offer(String::from(msg)).enter(|| {
    assert_eq!(&*illicit::expect::<String>(), msg);
});

Panics if the requested type is not in the environment:

This example panics
println!("{}", &*illicit::expect::<String>());