| Crates.io | pending_unwind |
| lib.rs | pending_unwind |
| version | 0.1.0 |
| created_at | 2025-03-08 11:23:02.701642+00 |
| updated_at | 2025-03-08 11:23:02.701642+00 |
| description | A library for converting unwindings into `pending`. |
| homepage | |
| repository | https://github.com/Ddystopia/pending_unwind |
| max_upload_size | |
| id | 1584328 |
| size | 19,429 |
pending_unwindMake any future non-unwinding. If [Future::poll] panics, it will be converted to [Poll::Pending]. One of the biggest problems with linear types is unwinding - what should you do duriing panic? They cannot be dropped, thus you cannot continue unwinding, and abort the program. This crate provides a way to convert unwinding to [Poll::Pending], so you can handle it in your own way.
A web server may use this to cancel all futures associated with a thread that panicked without having [catch_unwind].
let fut = pending_unwind(async { panic!() });
let mut fut = Box::pin(fut);
let mut cx = Context::from_waker(Waker::noop());
let poll = fut.as_mut().poll(&mut cx);
assert_eq!(poll, Poll::Pending);