/// 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_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)); /// ``` #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pubenum Resettable<T> { /// Overwrite builder value
Value(T), /// Reset builder value
Reset,
}
impl<T> From<Option<T>> for Resettable<T> {
fn from(other: Option<T>) -> Self { match other {
Some(inner) => Self::Value(inner),
None => Self::Reset,
}
}
}
/// Convert to the intended resettable type pubtrait IntoResettable<T> { /// Convert to the intended resettable type
fn into_resettable(self) -> Resettable<T>;
}
impl<I: Into<ValueRange>> IntoResettable<ValueRange> for I {
fn into_resettable(self) -> Resettable<ValueRange> {
Resettable::Value(self.into())
}
}
impl<I: Into<ValueParser>> IntoResettable<ValueParser> for I {
fn into_resettable(self) -> Resettable<ValueParser> {
Resettable::Value(self.into())
}
}
impl<I: Into<String>> IntoResettable<String> for I {
fn into_resettable(self) -> Resettable<String> {
Resettable::Value(self.into())
}
}
impl<I: Into<StyledStr>> IntoResettable<StyledStr> for I {
fn into_resettable(self) -> Resettable<StyledStr> {
Resettable::Value(self.into())
}
}
impl<I: Into<OsStr>> IntoResettable<OsStr> for I {
fn into_resettable(self) -> Resettable<OsStr> {
Resettable::Value(self.into())
}
}
impl<I: Into<Str>> IntoResettable<Str> for I {
fn into_resettable(self) -> Resettable<Str> {
Resettable::Value(self.into())
}
}
impl<I: Into<crate::Id>> IntoResettable<crate::Id> for I {
fn into_resettable(self) -> Resettable<crate::Id> {
Resettable::Value(self.into())
}
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.1Bemerkung:
(vorverarbeitet am 2026-10-12)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.