Skip to content

Commit

Permalink
docs: Clarify role of Resettable
Browse files Browse the repository at this point in the history
Inspired by #4554
  • Loading branch information
epage committed Dec 15, 2022
1 parent 25f9fda commit 1f3d5a3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/builder/resettable.rs
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

0 comments on commit 1f3d5a3

Please sign in to comment.