error_stack/compat/
eyre.rs1use eyre::Report as EyreReport;
2
3use crate::{Frame, IntoReportCompat, Report, Result};
4
5impl<T> IntoReportCompat for core::result::Result<T, EyreReport> {
6 type Err = EyreReport;
7 type Ok = T;
8
9 #[track_caller]
10 fn into_report(self) -> Result<T, EyreReport> {
11 match self {
12 Ok(t) => Ok(t),
13 Err(eyre) => {
14 let sources = eyre
15 .chain()
16 .skip(1)
17 .map(alloc::string::ToString::to_string)
18 .collect::<alloc::vec::Vec<_>>();
19
20 #[cfg_attr(not(feature = "std"), allow(unused_mut))]
21 let mut report = Report::from_frame(Frame::from_eyre(eyre, Box::new([])));
22
23 for source in sources {
24 report = report.attach_printable(source);
25 }
26
27 Err(report)
28 }
29 }
30 }
31}