/// An error type indicating that a component provided to a method was out of range, causing a /// failure. // i64 is the narrowest type fitting all use cases. This eliminates the need for a type parameter. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pubstruct ComponentRange { /// Name of the component. pub(crate) name: &'static str, /// Whether an input with the same value could have succeeded if the values of other components /// were different. pub(crate) is_conditional: bool,
}
impl ComponentRange { /// Create a new `ComponentRange` error that is not conditional. #[inline] pub(crate) constfn unconditional(name: &'static str) -> Self { Self {
name,
is_conditional: false,
}
}
/// Create a new `ComponentRange` error that is conditional. #[inline] pub(crate) constfn conditional(name: &'static str) -> Self { Self {
name,
is_conditional: true,
}
}
/// Obtain the name of the component whose value was out of range. #[inline] pubconstfn name(self) -> &'static str { self.name
}
/// Whether the value's permitted range is conditional, i.e. whether an input with this /// value could have succeeded if the values of other components were different. #[inline] pubconstfn is_conditional(self) -> bool { self.is_conditional
}
}
impl fmt::Display for ComponentRange { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} was not in range", self.name)
}
}
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.