mirror of
https://github.com/clap-rs/clap
synced 2024-11-14 00:27:13 +00:00
Merge pull request #5633 from epage/ext
fix(ext)!: Make extension methods fluent
This commit is contained in:
commit
d15c9affeb
3 changed files with 9 additions and 6 deletions
2
Makefile
2
Makefile
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue