1 2 3 4 5 6 7 8 9 10 11 12
pub trait JaapResult { fn for_error<F: FnOnce() -> ()>(self, f: F) -> Self; } impl<T, E> JaapResult for Result<T, E> { fn for_error<F: FnOnce() -> ()>(self, f: F) -> Self { if self.is_err() { f(); } self } }