Merge pull request #5633 from epage/ext

fix(ext)!: Make extension methods fluent
This commit is contained in:
Ed Page 2024-08-07 10:58:13 -05:00 committed by GitHub
commit d15c9affeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 6 deletions

View file

@ -16,7 +16,7 @@ _FEATURES = minimal default wasm full debug release
_FEATURES_minimal = --no-default-features --features "std" _FEATURES_minimal = --no-default-features --features "std"
_FEATURES_default = _FEATURES_default =
_FEATURES_wasm = --no-default-features --features "std help usage error-context suggestions" --features "deprecated derive cargo env unicode string" _FEATURES_wasm = --no-default-features --features "std help usage error-context suggestions" --features "deprecated derive cargo env unicode string"
_FEATURES_full = --features "deprecated derive cargo env unicode string wrap_help" _FEATURES_full = --features "deprecated derive cargo env unicode string wrap_help unstable-ext"
_FEATURES_next = ${_FEATURES_full} --features unstable-v5 _FEATURES_next = ${_FEATURES_full} --features unstable-v5
_FEATURES_debug = ${_FEATURES_full} --features debug --features clap_complete/debug _FEATURES_debug = ${_FEATURES_full} --features debug --features clap_complete/debug
_FEATURES_release = ${_FEATURES_full} --release _FEATURES_release = ${_FEATURES_full} --release

View file

@ -32,7 +32,7 @@ tag-name = "v{{version}}"
[features] [features]
default = ["std", "color", "help", "usage", "error-context", "suggestions"] default = ["std", "color", "help", "usage", "error-context", "suggestions"]
debug = ["dep:backtrace"] # Enables debug messages debug = ["dep:backtrace"] # Enables debug messages
unstable-doc = ["cargo", "wrap_help", "env", "unicode", "string"] # for docs.rs unstable-doc = ["cargo", "wrap_help", "env", "unicode", "string", "unstable-ext"] # for docs.rs
# Used in default # Used in default
std = ["anstyle/std"] # support for no_std in a backwards-compatible way std = ["anstyle/std"] # support for no_std in a backwards-compatible way

View file

@ -875,14 +875,17 @@ impl Arg {
/// Extend [`Arg`] with [`ArgExt`] data /// Extend [`Arg`] with [`ArgExt`] data
#[cfg(feature = "unstable-ext")] #[cfg(feature = "unstable-ext")]
pub fn add<T: ArgExt + Extension>(&mut self, tagged: T) -> bool { #[allow(clippy::should_implement_trait)]
self.ext.set(tagged) pub fn add<T: ArgExt + Extension>(mut self, tagged: T) -> Self {
self.ext.set(tagged);
self
} }
/// Remove an [`ArgExt`] /// Remove an [`ArgExt`]
#[cfg(feature = "unstable-ext")] #[cfg(feature = "unstable-ext")]
pub fn remove<T: ArgExt + Extension>(&mut self) -> Option<T> { pub fn remove<T: ArgExt + Extension>(mut self) -> Self {
self.ext.remove::<T>() self.ext.remove::<T>();
self
} }
} }