//! Extension traits for things either not implemented or not yet stable in the MSRV.
/// Marker trait for integer types. pub(crate) trait Integer: Sized { /// The maximum number of digits that this type can have. const MAX_NUM_DIGITS: u8; /// The zero value for this type. const ZERO: Self;
/// Push a digit onto the end of this integer, assuming no overflow. /// /// This is equivalent to `self * 10 + digit`. fn push_digit(self, digit: u8) -> Self;
/// Push a digit onto the end of this integer, returning `None` on overflow. /// /// This is equivalent to `self.checked_mul(10)?.checked_add(digit)`. fn checked_push_digit(self, digit: u8) -> Option<Self>;
}
/// Parse the given types from bytes.
macro_rules! impl_parse_bytes {
($($t:ty)*) => ($( impl Integer for $t { const MAX_NUM_DIGITS: u8 = matchSelf::MAX.checked_ilog10() {
Some(digits) => digits as u8 + 1,
None => 1,
};
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.