mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 06:44:16 +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_default =
|
||||
_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_debug = ${_FEATURES_full} --features debug --features clap_complete/debug
|
||||
_FEATURES_release = ${_FEATURES_full} --release
|
||||
|
|
|
@ -32,7 +32,7 @@ tag-name = "v{{version}}"
|
|||
[features]
|
||||
default = ["std", "color", "help", "usage", "error-context", "suggestions"]
|
||||
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
|
||||
std = ["anstyle/std"] # support for no_std in a backwards-compatible way
|
||||
|
|
|
@ -875,14 +875,17 @@ impl Arg {
|
|||
|
||||
/// Extend [`Arg`] with [`ArgExt`] data
|
||||
#[cfg(feature = "unstable-ext")]
|
||||
pub fn add<T: ArgExt + Extension>(&mut self, tagged: T) -> bool {
|
||||
self.ext.set(tagged)
|
||||
#[allow(clippy::should_implement_trait)]
|
||||
pub fn add<T: ArgExt + Extension>(mut self, tagged: T) -> Self {
|
||||
self.ext.set(tagged);
|
||||
self
|
||||
}
|
||||
|
||||
/// Remove an [`ArgExt`]
|
||||
#[cfg(feature = "unstable-ext")]
|
||||
pub fn remove<T: ArgExt + Extension>(&mut self) -> Option<T> {
|
||||
self.ext.remove::<T>()
|
||||
pub fn remove<T: ArgExt + Extension>(mut self) -> Self {
|
||||
self.ext.remove::<T>();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue