Wrap `FrameCursor` in a true iterator. This captures the `unwind` borrow for the duration of the iterator's lifetime. # Safety Safety conditions for this function are the same as for the [`FrameCursor::new`] function, plus the condition on `unwind` from the [`FrameCursor::advance`] method.
(
unwind: &dyn Unwind,
pc: usize,
fp: usize,
trampoline_fp: usize,
)
| 283 | /// [`FrameCursor::new`] function, plus the condition on `unwind` from |
| 284 | /// the [`FrameCursor::advance`] method. |
| 285 | pub unsafe fn frame_iterator( |
| 286 | unwind: &dyn Unwind, |
| 287 | pc: usize, |
| 288 | fp: usize, |
| 289 | trampoline_fp: usize, |
| 290 | ) -> impl Iterator<Item = Frame> { |
| 291 | // SAFETY: our safety conditions include those of |
| 292 | // `FrameCursor::new`. |
| 293 | let mut cursor = unsafe { FrameCursor::new(pc, fp, trampoline_fp) }; |
| 294 | core::iter::from_fn(move || { |
| 295 | if cursor.done() { |
| 296 | None |
| 297 | } else { |
| 298 | let frame = cursor.frame(); |
| 299 | // SAFETY: `unwind` is associated with the stack as per |
| 300 | // our safety conditions. |
| 301 | unsafe { |
| 302 | cursor.advance(unwind); |
| 303 | } |
| 304 | Some(frame) |
| 305 | } |
| 306 | }) |
| 307 | } |
| 308 | |
| 309 | /// Walk through a contiguous sequence of Wasm frames starting with |
| 310 | /// the frame at the given PC and FP and ending at |
no test coverage detected