Skip to main content

with_test_observer

Function with_test_observer 

Source
pub fn with_test_observer<F, R>(observer: Arc<dyn Observer>, f: F) -> R
where F: FnOnce() -> R,
Expand description

Test-flavored helper. Installs the observer per-thread for the duration of f; restores on closure exit. Used by #[obs::test] (Phase 2 task 2.6) and by users that want to assert what was emitted from a synchronous block.

Takes Arc<dyn Observer> so the caller can keep a clone and inspect it after the closure (e.g. InMemoryObserver::handle()). Spec 11 § 3.1.

Nested calls stack LIFO via the per-thread RefCell slot.