1use std::{convert::Infallible, error::Error};
2
3use crate::{Locations, NextError};
4
5pub trait ErrorExt: Error {
6 fn entry(&self) -> (&Locations, NextError<'_>);
7
8 fn locations(&mut self) -> &mut Locations;
9}
10
11impl ErrorExt for Infallible {
12 fn entry(&self) -> (&Locations, NextError<'_>) {
13 match *self {}
14 }
15
16 fn locations(&mut self) -> &mut Locations {
17 match *self {}
18 }
19}
20
21impl<T: ErrorExt> ErrorExt for Box<T> {
22 fn entry(&self) -> (&Locations, NextError<'_>) {
23 self.as_ref().entry()
24 }
25
26 fn locations(&mut self) -> &mut Locations {
27 self.as_mut().locations()
28 }
29}