[−][src]Macro topo::call
Calls the provided expression within an Env
bound to the callsite, optionally passing
an environment to the child scope.
let prev = topo::Id::current(); topo::call!(assert_ne!(prev, topo::Id::current()));
Adding an env! { ... }
directive to the macro input will take ownership of provided values
and make them available to the code run in the Point
created by the invocation.
#[derive(Debug, Eq, PartialEq)] struct Submarine(usize); assert!(topo::Env::get::<Submarine>().is_none()); topo::call!({ assert_eq!(&Submarine(1), &*topo::Env::get::<Submarine>().unwrap()); topo::call!({ assert_eq!(&Submarine(2), &*topo::Env::get::<Submarine>().unwrap()); }, env! { Submarine => Submarine(2), }); assert_eq!(&Submarine(1), &*topo::Env::get::<Submarine>().unwrap()); }, env! { Submarine => Submarine(1), }); assert!(topo::Env::get::<Submarine>().is_none());