MCPcopy Create free account
hub / github.com/hashintel/hash / downcast_mut

Method downcast_mut

libs/error-stack/src/report.rs:710–722  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

708 /// `T` can either be an attachment or a new [`Error`] context.
709 #[must_use]
710 pub fn downcast_mut<T: Send + Sync + 'static>(&mut self) -> Option<&mut T> {
711 // This cannot use `frames_mut` as the found reference needs to outlive the visitor
712 // closure. Each frame is either returned or descended into, never both, so the borrow
713 // checker accepts this without `unsafe`.
714 let mut stack = vec![self.frames.iter_mut()];
715 while let Some(frame) = iter::next(&mut stack) {
716 if frame.is::<T>() {
717 return frame.downcast_mut();
718 }
719 stack.push(frame.sources_mut().iter_mut());
720 }
721 None
722 }
723}
724
725impl<C> Report<[C]> {

Callers 2

get_mutMethod · 0.45
get_or_insert_withMethod · 0.45

Calls 4

sources_mutMethod · 0.80
nextFunction · 0.70
pushMethod · 0.65
iter_mutMethod · 0.45

Tested by

no test coverage detected