Allow contextualizing Option into Result
This commit is contained in:
@@ -233,6 +233,13 @@ impl<T, E: Into<Error>> Contextualize<Result<T, Error>> for Result<T, E> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Contextualize<Result<T, Error>> for Option<T> {
|
||||||
|
#[track_caller]
|
||||||
|
fn err_context(self, context: impl Into<String>) -> Result<T, Error> {
|
||||||
|
self.ok_or(Error::new_here(ErrorType::Error(context.into())))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<E: Into<Error>> Contextualize<Error> for E {
|
impl<E: Into<Error>> Contextualize<Error> for E {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn err_context(self, context: impl Into<String>) -> Error {
|
fn err_context(self, context: impl Into<String>) -> Error {
|
||||||
|
|||||||
Reference in New Issue
Block a user