Enum Resettable

pub enum Resettable<T>

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

# use clap_builder as clap;
# 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));

Variants

Value(T)

Overwrite builder value

Reset

Reset builder value

Trait Implementations

impl<T> From<Option<T>> for Resettable<T>

fn from(other: Option<T>) -> Self

impl<T> From<T> for Resettable<T>

fn from(other: T) -> Self

impl<T> IntoResettable<T> for Resettable<T>

fn into_resettable(self) -> Resettable<T>

impl<T: Clone> Clone for Resettable<T>

fn clone(&self) -> Resettable<T>

impl<T: Copy> Copy for Resettable<T>

impl<T: Debug> Debug for Resettable<T>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<T: Eq> Eq for Resettable<T>

impl<T: Hash> Hash for Resettable<T>

fn hash<__H: Hasher>(&self, state: &mut __H)

impl<T: Ord> Ord for Resettable<T>

fn cmp(&self, other: &Resettable<T>) -> Ordering

impl<T: PartialEq> PartialEq for Resettable<T>

fn eq(&self, other: &Resettable<T>) -> bool

impl<T: PartialEq> StructuralPartialEq for Resettable<T>

impl<T: PartialOrd> PartialOrd for Resettable<T>

fn partial_cmp(&self, other: &Resettable<T>) -> Option<Ordering>

Auto Trait Implementations

impl<T> Freeze for Resettable<T> where T: Freeze,

impl<T> RefUnwindSafe for Resettable<T> where T: RefUnwindSafe,

impl<T> Send for Resettable<T> where T: Send,

impl<T> Sync for Resettable<T> where T: Sync,

impl<T> Unpin for Resettable<T> where T: Unpin,

impl<T> UnsafeUnpin for Resettable<T> where T: UnsafeUnpin,

impl<T> UnwindSafe for Resettable<T> where T: UnwindSafe,

Blanket Implementations

impl<T> Any for Resettable<T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Resettable<T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Resettable<T> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Resettable<T> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Resettable<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> From<never> for Resettable<T>

fn from(t: never) -> T

impl<T> ToOwned for Resettable<T> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Resettable<T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Resettable<T> where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for Resettable<T> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>