hb_error 0.1.2

Useful macros and traits for creating and handling errors.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
/// The ErrorContext trait should be implemented for the context macro to work.
pub trait ErrorContext {
    fn make_inner(self) -> Self;
    fn msg<T: Into<String>>(self, msg: T) -> Self;
}
impl<O, E: ErrorContext> ErrorContext for Result<O, E> {
    fn make_inner(self) -> Self {
        self.map_err(|er| er.make_inner())
    }
    fn msg<T: Into<String>>(self, msg: T) -> Self {
        self.map_err(|er| er.msg(msg))
    }
}