pub enum Resettable<T> {
Value(T),
Reset,
}
Expand description
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
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§
Trait Implementations§
Source§impl<T> Clone for Resettable<T>where
T: Clone,
impl<T> Clone for Resettable<T>where
T: Clone,
Source§fn clone(&self) -> Resettable<T>
fn clone(&self) -> Resettable<T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T> Debug for Resettable<T>where
T: Debug,
impl<T> Debug for Resettable<T>where
T: Debug,
Source§impl<T> From<Option<T>> for Resettable<T>
impl<T> From<Option<T>> for Resettable<T>
Source§fn from(other: Option<T>) -> Resettable<T>
fn from(other: Option<T>) -> Resettable<T>
Converts to this type from the input type.
Source§impl<T> From<T> for Resettable<T>
impl<T> From<T> for Resettable<T>
Source§fn from(other: T) -> Resettable<T>
fn from(other: T) -> Resettable<T>
Converts to this type from the input type.
Source§impl<T> Hash for Resettable<T>where
T: Hash,
impl<T> Hash for Resettable<T>where
T: Hash,
Source§impl<T> IntoResettable<T> for Resettable<T>
impl<T> IntoResettable<T> for Resettable<T>
Source§fn into_resettable(self) -> Resettable<T>
fn into_resettable(self) -> Resettable<T>
Convert to the intended resettable type
Source§impl<T> Ord for Resettable<T>where
T: Ord,
impl<T> Ord for Resettable<T>where
T: Ord,
Source§fn cmp(&self, other: &Resettable<T>) -> Ordering
fn cmp(&self, other: &Resettable<T>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T> PartialEq for Resettable<T>where
T: PartialEq,
impl<T> PartialEq for Resettable<T>where
T: PartialEq,
Source§impl<T> PartialOrd for Resettable<T>where
T: PartialOrd,
impl<T> PartialOrd for Resettable<T>where
T: PartialOrd,
impl<T> Copy for Resettable<T>where
T: Copy,
impl<T> Eq for Resettable<T>where
T: Eq,
impl<T> StructuralPartialEq for Resettable<T>
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> UnwindSafe for Resettable<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.