| 572 | /// Please see the [`Error`] documentation for more information. |
| 573 | #[track_caller] |
| 574 | pub fn change_context<T>(mut self, context: T) -> Report<T> |
| 575 | where |
| 576 | T: Error + Send + Sync + 'static, |
| 577 | { |
| 578 | let old_frames = mem::replace(self.frames.as_mut(), Vec::with_capacity(1)); |
| 579 | let context_frame = vec![Frame::from_context(context, old_frames.into_boxed_slice())]; |
| 580 | self.frames.push(Frame::from_attachment( |
| 581 | *Location::caller(), |
| 582 | context_frame.into_boxed_slice(), |
| 583 | )); |
| 584 | Report { |
| 585 | frames: self.frames, |
| 586 | _context: PhantomData, |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | /// Returns an iterator over the [`Frame`] stack of the report. |
| 591 | pub fn frames(&self) -> Frames<'_> { |