Thanks to visit codestin.com
Credit goes to docs.rs

error_stack/compat/
eyre.rs

1use eyre::Report as EyreReport;
2
3use crate::{Frame, IntoReportCompat, Report};
4
5impl<T> IntoReportCompat for Result<T, EyreReport> {
6    type Err = EyreReport;
7    type Ok = T;
8
9    #[track_caller]
10    fn into_report(self) -> Result<T, Report<EyreReport>> {
11        match self {
12            Ok(value) => Ok(value),
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<EyreReport> =
22                    Report::from_frame(Frame::from_eyre(eyre, Box::new([])));
23
24                for source in sources {
25                    report = report.attach(source);
26                }
27
28                Err(report)
29            }
30        }
31    }
32}