You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fcmp/fcmprs/src/error.rs

21 lines
356 B

pub trait ResultPrintExt<T>
{
fn discard_msg(self, msg: impl AsRef<str>) -> Option<T>;
}
impl<T, E> ResultPrintExt<T> for Result<T,E>
where E: std::fmt::Display
{
fn discard_msg(self, msg: impl AsRef<str>) -> Option<T> {
match self {
Ok(v) => Some(v),
Err(e) => {
eprintln!("{}: {}", msg.as_ref(), e);
None
},
}
}
}