Skip to content

Commit

Permalink
Merge pull request #5633 from epage/ext
Browse files Browse the repository at this point in the history
fix(ext)!: Make extension methods fluent
  • Loading branch information
epage authored Aug 7, 2024
2 parents edcaf8f + 1153858 commit d15c9af
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion clap_builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions clap_builder/src/builder/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit d15c9af

Please sign in to comment.