1 | use crate::OptionExt; |
---|---|
2 | use core::fmt::{Debug, Display}; |
3 | |
4 | impl<T> OptionExt<T> for Option<T> { |
5 | #[track_caller] |
6 | fn ok_or_eyre<M>(self, message: M) -> crate::Result<T> |
7 | where |
8 | M: Debug + Display + Send + Sync + 'static, |
9 | { |
10 | match self { |
11 | Some(ok: T) => Ok(ok), |
12 | None => Err(crate::Report::msg(message)), |
13 | } |
14 | } |
15 | } |
16 |
Definitions
Learn Rust with the experts
Find out more