Open soywod opened 1 year ago
I got a working implementation:
pub trait UnwrapOrWarn<T, W> {
fn unwrap_or_warn(self, warning: W) -> warned::Warned<T, W>;
}
impl<T: Default, W> UnwrapOrWarn<T, W> for Option<T> {
fn unwrap_or_warn(self, warning: W) -> warned::Warned<T, W> {
match self {
Some(t) => warned::Warned::new(t, Vec::default()),
None => warned::Warned::new(Default::default(), vec![warning]),
}
}
}
It could be nice to add function to unwrap an
Option
into aWarned
, sth like: