pub struct CatchAssertUnwindSafe<H> { /* private fields */ }Expand description
Panic-catching wrapper for Handler implementations.
Catches panics during run() so the handler is never
lost during move-out-fire dispatch. This is an annotation — wrap a
concrete handler, then virtualize through your chosen storage (Box,
Flat, Flex, typed slab, etc.).
By constructing this wrapper, the user asserts that the inner handler
(and any World resources it mutates) can tolerate partial writes
caused by an unwound run() call. This is the same assertion as
std::panic::AssertUnwindSafe, applied at the handler level.
§Examples
use nexus_rt::{CatchAssertUnwindSafe, WorldBuilder, ResMut, IntoHandler, Handler, Virtual};
fn tick(mut counter: ResMut<u64>, event: u32) {
*counter += event as u64;
}
let mut builder = WorldBuilder::new();
builder.register::<u64>(0);
let mut world = builder.build();
let handler = tick.into_handler(world.registry());
let guarded = CatchAssertUnwindSafe::new(handler);
let mut boxed: Virtual<u32> = Box::new(guarded);
boxed.run(&mut world, 10);
assert_eq!(*world.resource::<u64>(), 10);Implementations§
Source§impl<H> CatchAssertUnwindSafe<H>
impl<H> CatchAssertUnwindSafe<H>
Trait Implementations§
Auto Trait Implementations§
impl<H> Freeze for CatchAssertUnwindSafe<H>where
H: Freeze,
impl<H> RefUnwindSafe for CatchAssertUnwindSafe<H>where
H: RefUnwindSafe,
impl<H> Send for CatchAssertUnwindSafe<H>where
H: Send,
impl<H> Sync for CatchAssertUnwindSafe<H>where
H: Sync,
impl<H> Unpin for CatchAssertUnwindSafe<H>where
H: Unpin,
impl<H> UnsafeUnpin for CatchAssertUnwindSafe<H>where
H: UnsafeUnpin,
impl<H> UnwindSafe for CatchAssertUnwindSafe<H>where
H: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more