From 7e65f3ef9971cca97fe656ca089bdb55a98a09ec Mon Sep 17 00:00:00 2001 From: morganamilo Date: Mon, 4 Dec 2023 15:07:52 +0000 Subject: [PATCH] feat(error): Allow removing context from errors --- clap_builder/src/error/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/clap_builder/src/error/mod.rs b/clap_builder/src/error/mod.rs index 210a1717f1f0..61e05231335a 100644 --- a/clap_builder/src/error/mod.rs +++ b/clap_builder/src/error/mod.rs @@ -201,6 +201,13 @@ impl Error { self.inner.context.insert(kind, value) } + /// remove a piece of context + #[inline(never)] + #[cfg(feature = "error-context")] + pub fn remove(&mut self, kind: ContextKind) -> Option { + self.inner.context.remove(&kind) + } + /// Should the message be written to `stdout` or not? #[inline] pub fn use_stderr(&self) -> bool {