From ff2aba4ec484fd4f1b0e6d96a28f1ccdc28cc49a Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Sun, 21 Jun 2026 12:27:47 -0400 Subject: [PATCH] Allow contextualizing Option into Result --- src/util/error.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util/error.rs b/src/util/error.rs index 663dab8..c3e5b25 100644 --- a/src/util/error.rs +++ b/src/util/error.rs @@ -233,6 +233,13 @@ impl> Contextualize> for Result { } } +impl Contextualize> for Option { + #[track_caller] + fn err_context(self, context: impl Into) -> Result { + self.ok_or(Error::new_here(ErrorType::Error(context.into()))) + } +} + impl> Contextualize for E { #[track_caller] fn err_context(self, context: impl Into) -> Error {