[−][src]Trait revent::Suspend
Suspend an arbitrary reference from access.
Provided methods
fn suspend<F: FnOnce() -> R, R>(&mut self, runner: F) -> R where
Self: Sized,
Self: Sized,
Suspend this object and run runner
, which by using another data structure can reborrow
&mut Self
without violating the mutable aliasing rules.
Only the last emitted object can be suspended.
Panics
Panics if the suspended object is not stored in a Node, or if the object is not at the top of the current node stack.
use revent::{Node, Suspend}; let node1 = Node::new(()); let node2 = Node::new(()); node1.emit(|x1| { node2.emit(|x2| { x1.suspend(|| {}); // Panic, `node2` was last emitted, we can't suspend `x1`, which // comes from `node1`. }); });