Skip to content

Commit

Permalink
Merge pull request clap-rs#4555 from epage/reset
Browse files Browse the repository at this point in the history
docs: Clarify role of Resettable
  • Loading branch information
epage authored Dec 15, 2022
2 parents 922fc00 + 16c499c commit aa54204
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/builder/resettable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ use crate::builder::ValueParser;
use crate::builder::ValueRange;

/// Clearable builder value
///
/// This allows a builder function to both accept any value that can [`Into::into`] `T` (like
/// `&str` into `OsStr`) as well as `None` to reset it to the default. This is needed to
/// workaround a limitation where you can't have a function argument that is `impl Into<Option<T>>`
/// where `T` is `impl Into<S>` accept `None` as its type is ambiguous.
///
/// # Example
///
/// ```rust
/// # use clap::Command;
/// # use clap::Arg;
/// fn common() -> Command {
/// Command::new("cli")
/// .arg(Arg::new("input").short('i').long("input"))
/// }
/// let mut command = common();
/// command.mut_arg("input", |arg| arg.short(None));
/// ```
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Resettable<T> {
/// Overwrite builder value
Expand Down
3 changes: 3 additions & 0 deletions src/builder/styled_str.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/// Terminal-styling container
///
/// For now, this is the same as a [`Str`][crate::builder::Str]. This exists to reserve space in
/// the API for exposing terminal styling.
#[derive(Clone, Default, Debug, PartialEq, Eq)]
pub struct StyledStr {
#[cfg(feature = "color")]
Expand Down

0 comments on commit aa54204

Please sign in to comment.