summaryrefslogtreecommitdiffstats
path: root/vendor/anyhow/src/context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/anyhow/src/context.rs')
-rw-r--r--vendor/anyhow/src/context.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/vendor/anyhow/src/context.rs b/vendor/anyhow/src/context.rs
index 1b7dd31ac..238473e5c 100644
--- a/vendor/anyhow/src/context.rs
+++ b/vendor/anyhow/src/context.rs
@@ -47,7 +47,12 @@ where
where
C: Display + Send + Sync + 'static,
{
- self.map_err(|error| error.ext_context(context))
+ // Not using map_err to save 2 useless frames off the captured backtrace
+ // in ext_context.
+ match self {
+ Ok(ok) => Ok(ok),
+ Err(error) => Err(error.ext_context(context)),
+ }
}
fn with_context<C, F>(self, context: F) -> Result<T, Error>
@@ -55,7 +60,10 @@ where
C: Display + Send + Sync + 'static,
F: FnOnce() -> C,
{
- self.map_err(|error| error.ext_context(context()))
+ match self {
+ Ok(ok) => Ok(ok),
+ Err(error) => Err(error.ext_context(context())),
+ }
}
}