(future: F)
| 52 | } |
| 53 | |
| 54 | fn block_on<F: Future>(future: F) -> F::Output { |
| 55 | const MAX_POLLS: u32 = 100_000; |
| 56 | |
| 57 | let mut f = Box::pin(future); |
| 58 | let mut cx = Context::from_waker(Waker::noop()); |
| 59 | for _ in 0..MAX_POLLS { |
| 60 | match f.as_mut().poll(&mut cx) { |
| 61 | Poll::Ready(val) => return val, |
| 62 | Poll::Pending => {} |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | panic!("future didn't become ready") |
| 67 | } |
| 68 | |
| 69 | /// Helper future to yield N times before resolving. |
| 70 | struct YieldN(u32); |
no test coverage detected