pub trait CountDigits: Copy + Sized {
type Radix;
// Required methods
fn count_bits(self) -> u32;
fn count_octal_digits(self) -> u32;
fn count_hex_digits(self) -> u32;
fn count_digits(self) -> usize;
fn count_digits_radix(self, radix: Self::Radix) -> usize;
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>;
}
Expand description
A no-std trait to determine lengths of integers in various number bases.
Required Associated Types§
Sourcetype Radix
type Radix
The type of integer that should be passed to the count_digits_radix() and checked_count_digits_radix() functions.
This is always the corresponding unsigned primitive type for an integer of a given size.
For example, u8 is the Radix type for i8, u8, NonZeroI8, and NonZeroU8.
Required Methods§
Sourcefn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
§Examples
use count_digits::CountDigits;
assert_eq!(008, i8::MIN.count_bits());
assert_eq!(007, i8::MAX.count_bits());
assert_eq!(008, NonZeroI8::MIN.count_bits());
assert_eq!(007, NonZeroI8::MAX.count_bits());
assert_eq!(001, u8::MIN.count_bits());
assert_eq!(008, u8::MAX.count_bits());
assert_eq!(001, NonZeroU8::MIN.count_bits());
assert_eq!(008, NonZeroU8::MAX.count_bits());
assert_eq!(016, i16::MIN.count_bits());
assert_eq!(015, i16::MAX.count_bits());
assert_eq!(016, NonZeroI16::MIN.count_bits());
assert_eq!(015, NonZeroI16::MAX.count_bits());
assert_eq!(001, u16::MIN.count_bits());
assert_eq!(016, u16::MAX.count_bits());
assert_eq!(001, NonZeroU16::MIN.count_bits());
assert_eq!(016, NonZeroU16::MAX.count_bits());
assert_eq!(032, i32::MIN.count_bits());
assert_eq!(031, i32::MAX.count_bits());
assert_eq!(032, NonZeroI32::MIN.count_bits());
assert_eq!(031, NonZeroI32::MAX.count_bits());
assert_eq!(001, u32::MIN.count_bits());
assert_eq!(032, u32::MAX.count_bits());
assert_eq!(001, NonZeroU32::MIN.count_bits());
assert_eq!(032, NonZeroU32::MAX.count_bits());
assert_eq!(064, i64::MIN.count_bits());
assert_eq!(063, i64::MAX.count_bits());
assert_eq!(064, NonZeroI64::MIN.count_bits());
assert_eq!(063, NonZeroI64::MAX.count_bits());
assert_eq!(001, u64::MIN.count_bits());
assert_eq!(064, u64::MAX.count_bits());
assert_eq!(001, NonZeroU64::MIN.count_bits());
assert_eq!(064, NonZeroU64::MAX.count_bits());
assert_eq!(128, i128::MIN.count_bits());
assert_eq!(127, i128::MAX.count_bits());
assert_eq!(128, NonZeroI128::MIN.count_bits());
assert_eq!(127, NonZeroI128::MAX.count_bits());
assert_eq!(001, u128::MIN.count_bits());
assert_eq!(128, u128::MAX.count_bits());
assert_eq!(001, NonZeroU128::MIN.count_bits());
assert_eq!(128, NonZeroU128::MAX.count_bits());
#[cfg(target_pointer_width = "64")] {
assert_eq!(isize::MIN.count_bits(), i64::MIN.count_bits());
assert_eq!(isize::MAX.count_bits(), i64::MAX.count_bits());
assert_eq!(NonZeroIsize::MIN.count_bits(), NonZeroI64::MIN.count_bits());
assert_eq!(NonZeroIsize::MAX.count_bits(), NonZeroI64::MAX.count_bits());
assert_eq!(usize::MIN.count_bits(), u64::MIN.count_bits());
assert_eq!(usize::MAX.count_bits(), u64::MAX.count_bits());
assert_eq!(NonZeroUsize::MIN.count_bits(), NonZeroU64::MIN.count_bits());
assert_eq!(NonZeroUsize::MAX.count_bits(), NonZeroU64::MAX.count_bits());
}
#[cfg(target_pointer_width = "32")] {
assert_eq!(isize::MIN.count_bits(), i32::MIN.count_bits());
assert_eq!(isize::MAX.count_bits(), i32::MAX.count_bits());
assert_eq!(NonZeroIsize::MIN.count_bits(), NonZeroI32::MIN.count_bits());
assert_eq!(NonZeroIsize::MAX.count_bits(), NonZeroI32::MAX.count_bits());
assert_eq!(usize::MIN.count_bits(), u32::MIN.count_bits());
assert_eq!(usize::MAX.count_bits(), u32::MAX.count_bits());
assert_eq!(NonZeroUsize::MIN.count_bits(), NonZeroU32::MIN.count_bits());
assert_eq!(NonZeroUsize::MAX.count_bits(), NonZeroU32::MAX.count_bits());
}
#[cfg(target_pointer_width = "16")] {
assert_eq!(isize::MIN.count_bits(), i16::MIN.count_bits());
assert_eq!(isize::MAX.count_bits(), i16::MAX.count_bits());
assert_eq!(NonZeroIsize::MIN.count_bits(), NonZeroI16::MIN.count_bits());
assert_eq!(NonZeroIsize::MAX.count_bits(), NonZeroI16::MAX.count_bits());
assert_eq!(usize::MIN.count_bits(), u16::MIN.count_bits());
assert_eq!(usize::MAX.count_bits(), u16::MAX.count_bits());
assert_eq!(NonZeroUsize::MIN.count_bits(), NonZeroU16::MIN.count_bits());
assert_eq!(NonZeroUsize::MAX.count_bits(), NonZeroU16::MAX.count_bits());
}
#[cfg(target_pointer_width = "8")] {
assert_eq!(isize::MIN.count_bits(), i8::MIN.count_bits());
assert_eq!(isize::MAX.count_bits(), i8::MAX.count_bits());
assert_eq!(NonZeroIsize::MIN.count_bits(), NonZeroI8::MIN.count_bits());
assert_eq!(NonZeroIsize::MAX.count_bits(), NonZeroI8::MAX.count_bits());
assert_eq!(usize::MIN.count_bits(), u8::MIN.count_bits());
assert_eq!(usize::MAX.count_bits(), u8::MAX.count_bits());
assert_eq!(NonZeroUsize::MIN.count_bits(), NonZeroU8::MIN.count_bits());
assert_eq!(NonZeroUsize::MAX.count_bits(), NonZeroU8::MAX.count_bits());
}
Sourcefn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
§Examples
use count_digits::CountDigits;
assert_eq!(03, i8::MIN.count_octal_digits());
assert_eq!(03, i8::MAX.count_octal_digits());
assert_eq!(03, NonZeroI8::MIN.count_octal_digits());
assert_eq!(03, NonZeroI8::MAX.count_octal_digits());
assert_eq!(01, u8::MIN.count_octal_digits());
assert_eq!(03, u8::MAX.count_octal_digits());
assert_eq!(01, NonZeroU8::MIN.count_octal_digits());
assert_eq!(03, NonZeroU8::MAX.count_octal_digits());
assert_eq!(06, i16::MIN.count_octal_digits());
assert_eq!(05, i16::MAX.count_octal_digits());
assert_eq!(06, NonZeroI16::MIN.count_octal_digits());
assert_eq!(05, NonZeroI16::MAX.count_octal_digits());
assert_eq!(01, u16::MIN.count_octal_digits());
assert_eq!(06, u16::MAX.count_octal_digits());
assert_eq!(01, NonZeroU16::MIN.count_octal_digits());
assert_eq!(06, NonZeroU16::MAX.count_octal_digits());
assert_eq!(11, i32::MIN.count_octal_digits());
assert_eq!(11, i32::MAX.count_octal_digits());
assert_eq!(11, NonZeroI32::MIN.count_octal_digits());
assert_eq!(11, NonZeroI32::MAX.count_octal_digits());
assert_eq!(01, u32::MIN.count_octal_digits());
assert_eq!(11, u32::MAX.count_octal_digits());
assert_eq!(01, NonZeroU32::MIN.count_octal_digits());
assert_eq!(11, NonZeroU32::MAX.count_octal_digits());
assert_eq!(22, i64::MIN.count_octal_digits());
assert_eq!(21, i64::MAX.count_octal_digits());
assert_eq!(22, NonZeroI64::MIN.count_octal_digits());
assert_eq!(21, NonZeroI64::MAX.count_octal_digits());
assert_eq!(01, u64::MIN.count_octal_digits());
assert_eq!(22, u64::MAX.count_octal_digits());
assert_eq!(01, NonZeroU64::MIN.count_octal_digits());
assert_eq!(22, NonZeroU64::MAX.count_octal_digits());
assert_eq!(43, i128::MIN.count_octal_digits());
assert_eq!(43, i128::MAX.count_octal_digits());
assert_eq!(43, NonZeroI128::MIN.count_octal_digits());
assert_eq!(43, NonZeroI128::MAX.count_octal_digits());
assert_eq!(01, u128::MIN.count_octal_digits());
assert_eq!(43, u128::MAX.count_octal_digits());
assert_eq!(01, NonZeroU128::MIN.count_octal_digits());
assert_eq!(43, NonZeroU128::MAX.count_octal_digits());
#[cfg(target_pointer_width = "64")] {
assert_eq!(isize::MIN.count_octal_digits(), i64::MIN.count_octal_digits());
assert_eq!(isize::MAX.count_octal_digits(), i64::MAX.count_octal_digits());
assert_eq!(NonZeroIsize::MIN.count_octal_digits(), NonZeroI64::MIN.count_octal_digits());
assert_eq!(NonZeroIsize::MAX.count_octal_digits(), NonZeroI64::MAX.count_octal_digits());
assert_eq!(usize::MIN.count_octal_digits(), u64::MIN.count_octal_digits());
assert_eq!(usize::MAX.count_octal_digits(), u64::MAX.count_octal_digits());
assert_eq!(NonZeroUsize::MIN.count_octal_digits(), NonZeroU64::MIN.count_octal_digits());
assert_eq!(NonZeroUsize::MAX.count_octal_digits(), NonZeroU64::MAX.count_octal_digits());
}
#[cfg(target_pointer_width = "32")] {
assert_eq!(isize::MIN.count_octal_digits(), i32::MIN.count_octal_digits());
assert_eq!(isize::MAX.count_octal_digits(), i32::MAX.count_octal_digits());
assert_eq!(NonZeroIsize::MIN.count_octal_digits(), NonZeroI32::MIN.count_octal_digits());
assert_eq!(NonZeroIsize::MAX.count_octal_digits(), NonZeroI32::MAX.count_octal_digits());
assert_eq!(usize::MIN.count_octal_digits(), u32::MIN.count_octal_digits());
assert_eq!(usize::MAX.count_octal_digits(), u32::MAX.count_octal_digits());
assert_eq!(NonZeroUsize::MIN.count_octal_digits(), NonZeroU32::MIN.count_octal_digits());
assert_eq!(NonZeroUsize::MAX.count_octal_digits(), NonZeroU32::MAX.count_octal_digits());
}
#[cfg(target_pointer_width = "16")] {
assert_eq!(isize::MIN.count_octal_digits(), i16::MIN.count_octal_digits());
assert_eq!(isize::MAX.count_octal_digits(), i16::MAX.count_octal_digits());
assert_eq!(NonZeroIsize::MIN.count_octal_digits(), NonZeroI16::MIN.count_octal_digits());
assert_eq!(NonZeroIsize::MAX.count_octal_digits(), NonZeroI16::MAX.count_octal_digits());
assert_eq!(usize::MIN.count_octal_digits(), u16::MIN.count_octal_digits());
assert_eq!(usize::MAX.count_octal_digits(), u16::MAX.count_octal_digits());
assert_eq!(NonZeroUsize::MIN.count_octal_digits(), NonZeroU16::MIN.count_octal_digits());
assert_eq!(NonZeroUsize::MAX.count_octal_digits(), NonZeroU16::MAX.count_octal_digits());
}
#[cfg(target_pointer_width = "8")] {
assert_eq!(isize::MIN.count_octal_digits(), i8::MIN.count_octal_digits());
assert_eq!(isize::MAX.count_octal_digits(), i8::MAX.count_octal_digits());
assert_eq!(NonZeroIsize::MIN.count_octal_digits(), NonZeroI8::MIN.count_octal_digits());
assert_eq!(NonZeroIsize::MAX.count_octal_digits(), NonZeroI8::MAX.count_octal_digits());
assert_eq!(usize::MIN.count_octal_digits(), u8::MIN.count_octal_digits());
assert_eq!(usize::MAX.count_octal_digits(), u8::MAX.count_octal_digits());
assert_eq!(NonZeroUsize::MIN.count_octal_digits(), NonZeroU8::MIN.count_octal_digits());
assert_eq!(NonZeroUsize::MAX.count_octal_digits(), NonZeroU8::MAX.count_octal_digits());
}
Sourcefn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
§Examples
use count_digits::CountDigits;
assert_eq!(02, i8::MIN.count_hex_digits());
assert_eq!(02, i8::MAX.count_hex_digits());
assert_eq!(02, NonZeroI8::MIN.count_hex_digits());
assert_eq!(02, NonZeroI8::MAX.count_hex_digits());
assert_eq!(01, u8::MIN.count_hex_digits());
assert_eq!(02, u8::MAX.count_hex_digits());
assert_eq!(01, NonZeroU8::MIN.count_hex_digits());
assert_eq!(02, NonZeroU8::MAX.count_hex_digits());
assert_eq!(04, i16::MIN.count_hex_digits());
assert_eq!(04, i16::MAX.count_hex_digits());
assert_eq!(04, NonZeroI16::MIN.count_hex_digits());
assert_eq!(04, NonZeroI16::MAX.count_hex_digits());
assert_eq!(01, u16::MIN.count_hex_digits());
assert_eq!(04, u16::MAX.count_hex_digits());
assert_eq!(01, NonZeroU16::MIN.count_hex_digits());
assert_eq!(04, NonZeroU16::MAX.count_hex_digits());
assert_eq!(08, i32::MIN.count_hex_digits());
assert_eq!(08, i32::MAX.count_hex_digits());
assert_eq!(08, NonZeroI32::MIN.count_hex_digits());
assert_eq!(08, NonZeroI32::MAX.count_hex_digits());
assert_eq!(01, u32::MIN.count_hex_digits());
assert_eq!(08, u32::MAX.count_hex_digits());
assert_eq!(01, NonZeroU32::MIN.count_hex_digits());
assert_eq!(08, NonZeroU32::MAX.count_hex_digits());
assert_eq!(16, i64::MIN.count_hex_digits());
assert_eq!(16, i64::MAX.count_hex_digits());
assert_eq!(16, NonZeroI64::MIN.count_hex_digits());
assert_eq!(16, NonZeroI64::MAX.count_hex_digits());
assert_eq!(01, u64::MIN.count_hex_digits());
assert_eq!(16, u64::MAX.count_hex_digits());
assert_eq!(01, NonZeroU64::MIN.count_hex_digits());
assert_eq!(16, NonZeroU64::MAX.count_hex_digits());
assert_eq!(32, i128::MIN.count_hex_digits());
assert_eq!(32, i128::MAX.count_hex_digits());
assert_eq!(32, NonZeroI128::MIN.count_hex_digits());
assert_eq!(32, NonZeroI128::MAX.count_hex_digits());
assert_eq!(01, u128::MIN.count_hex_digits());
assert_eq!(32, u128::MAX.count_hex_digits());
assert_eq!(01, NonZeroU128::MIN.count_hex_digits());
assert_eq!(32, NonZeroU128::MAX.count_hex_digits());
#[cfg(target_pointer_width = "64")] {
assert_eq!(isize::MIN.count_hex_digits(), i64::MIN.count_hex_digits());
assert_eq!(isize::MAX.count_hex_digits(), i64::MAX.count_hex_digits());
assert_eq!(NonZeroIsize::MIN.count_hex_digits(), NonZeroI64::MIN.count_hex_digits());
assert_eq!(NonZeroIsize::MAX.count_hex_digits(), NonZeroI64::MAX.count_hex_digits());
assert_eq!(usize::MIN.count_hex_digits(), u64::MIN.count_hex_digits());
assert_eq!(usize::MAX.count_hex_digits(), u64::MAX.count_hex_digits());
assert_eq!(NonZeroUsize::MIN.count_hex_digits(), NonZeroU64::MIN.count_hex_digits());
assert_eq!(NonZeroUsize::MAX.count_hex_digits(), NonZeroU64::MAX.count_hex_digits());
}
#[cfg(target_pointer_width = "32")] {
assert_eq!(isize::MIN.count_hex_digits(), i32::MIN.count_hex_digits());
assert_eq!(isize::MAX.count_hex_digits(), i32::MAX.count_hex_digits());
assert_eq!(NonZeroIsize::MIN.count_hex_digits(), NonZeroI32::MIN.count_hex_digits());
assert_eq!(NonZeroIsize::MAX.count_hex_digits(), NonZeroI32::MAX.count_hex_digits());
assert_eq!(usize::MIN.count_hex_digits(), u32::MIN.count_hex_digits());
assert_eq!(usize::MAX.count_hex_digits(), u32::MAX.count_hex_digits());
assert_eq!(NonZeroUsize::MIN.count_hex_digits(), NonZeroU32::MIN.count_hex_digits());
assert_eq!(NonZeroUsize::MAX.count_hex_digits(), NonZeroU32::MAX.count_hex_digits());
}
#[cfg(target_pointer_width = "16")] {
assert_eq!(isize::MIN.count_hex_digits(), i16::MIN.count_hex_digits());
assert_eq!(isize::MAX.count_hex_digits(), i16::MAX.count_hex_digits());
assert_eq!(NonZeroIsize::MIN.count_hex_digits(), NonZeroI16::MIN.count_hex_digits());
assert_eq!(NonZeroIsize::MAX.count_hex_digits(), NonZeroI16::MAX.count_hex_digits());
assert_eq!(usize::MIN.count_hex_digits(), u16::MIN.count_hex_digits());
assert_eq!(usize::MAX.count_hex_digits(), u16::MAX.count_hex_digits());
assert_eq!(NonZeroUsize::MIN.count_hex_digits(), NonZeroU16::MIN.count_hex_digits());
assert_eq!(NonZeroUsize::MAX.count_hex_digits(), NonZeroU16::MAX.count_hex_digits());
}
#[cfg(target_pointer_width = "8")] {
assert_eq!(isize::MIN.count_hex_digits(), i8::MIN.count_hex_digits());
assert_eq!(isize::MAX.count_hex_digits(), i8::MAX.count_hex_digits());
assert_eq!(NonZeroIsize::MIN.count_hex_digits(), NonZeroI8::MIN.count_hex_digits());
assert_eq!(NonZeroIsize::MAX.count_hex_digits(), NonZeroI8::MAX.count_hex_digits());
assert_eq!(usize::MIN.count_hex_digits(), u8::MIN.count_hex_digits());
assert_eq!(usize::MAX.count_hex_digits(), u8::MAX.count_hex_digits());
assert_eq!(NonZeroUsize::MIN.count_hex_digits(), NonZeroU8::MIN.count_hex_digits());
assert_eq!(NonZeroUsize::MAX.count_hex_digits(), NonZeroU8::MAX.count_hex_digits());
}
Sourcefn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
§Examples
use count_digits::CountDigits;
assert_eq!(03, i8::MIN.count_digits());
assert_eq!(03, i8::MAX.count_digits());
assert_eq!(03, NonZeroI8::MIN.count_digits());
assert_eq!(03, NonZeroI8::MAX.count_digits());
assert_eq!(01, u8::MIN.count_digits());
assert_eq!(03, u8::MAX.count_digits());
assert_eq!(01, NonZeroU8::MIN.count_digits());
assert_eq!(03, NonZeroU8::MAX.count_digits());
assert_eq!(05, i16::MIN.count_digits());
assert_eq!(05, i16::MAX.count_digits());
assert_eq!(05, NonZeroI16::MIN.count_digits());
assert_eq!(05, NonZeroI16::MAX.count_digits());
assert_eq!(01, u16::MIN.count_digits());
assert_eq!(05, u16::MAX.count_digits());
assert_eq!(01, NonZeroU16::MIN.count_digits());
assert_eq!(05, NonZeroU16::MAX.count_digits());
assert_eq!(10, i32::MIN.count_digits());
assert_eq!(10, i32::MAX.count_digits());
assert_eq!(10, NonZeroI32::MIN.count_digits());
assert_eq!(10, NonZeroI32::MAX.count_digits());
assert_eq!(01, u32::MIN.count_digits());
assert_eq!(10, u32::MAX.count_digits());
assert_eq!(01, NonZeroU32::MIN.count_digits());
assert_eq!(10, NonZeroU32::MAX.count_digits());
assert_eq!(19, i64::MIN.count_digits());
assert_eq!(19, i64::MAX.count_digits());
assert_eq!(19, NonZeroI64::MIN.count_digits());
assert_eq!(19, NonZeroI64::MAX.count_digits());
assert_eq!(01, u64::MIN.count_digits());
assert_eq!(20, u64::MAX.count_digits());
assert_eq!(01, NonZeroU64::MIN.count_digits());
assert_eq!(20, NonZeroU64::MAX.count_digits());
assert_eq!(39, i128::MIN.count_digits());
assert_eq!(39, i128::MAX.count_digits());
assert_eq!(39, NonZeroI128::MIN.count_digits());
assert_eq!(39, NonZeroI128::MAX.count_digits());
assert_eq!(01, u128::MIN.count_digits());
assert_eq!(39, u128::MAX.count_digits());
assert_eq!(01, NonZeroU128::MIN.count_digits());
assert_eq!(39, NonZeroU128::MAX.count_digits());
#[cfg(target_pointer_width = "64")] {
assert_eq!(isize::MIN.count_digits(), i64::MIN.count_digits());
assert_eq!(isize::MAX.count_digits(), i64::MAX.count_digits());
assert_eq!(NonZeroIsize::MIN.count_digits(), NonZeroI64::MIN.count_digits());
assert_eq!(NonZeroIsize::MAX.count_digits(), NonZeroI64::MAX.count_digits());
assert_eq!(usize::MIN.count_digits(), u64::MIN.count_digits());
assert_eq!(usize::MAX.count_digits(), u64::MAX.count_digits());
assert_eq!(NonZeroUsize::MIN.count_digits(), NonZeroU64::MIN.count_digits());
assert_eq!(NonZeroUsize::MAX.count_digits(), NonZeroU64::MAX.count_digits());
}
#[cfg(target_pointer_width = "32")] {
assert_eq!(isize::MIN.count_digits(), i32::MIN.count_digits());
assert_eq!(isize::MAX.count_digits(), i32::MAX.count_digits());
assert_eq!(NonZeroIsize::MIN.count_digits(), NonZeroI32::MIN.count_digits());
assert_eq!(NonZeroIsize::MAX.count_digits(), NonZeroI32::MAX.count_digits());
assert_eq!(usize::MIN.count_digits(), u32::MIN.count_digits());
assert_eq!(usize::MAX.count_digits(), u32::MAX.count_digits());
assert_eq!(NonZeroUsize::MIN.count_digits(), NonZeroU32::MIN.count_digits());
assert_eq!(NonZeroUsize::MAX.count_digits(), NonZeroU32::MAX.count_digits());
}
#[cfg(target_pointer_width = "16")] {
assert_eq!(isize::MIN.count_digits(), i16::MIN.count_digits());
assert_eq!(isize::MAX.count_digits(), i16::MAX.count_digits());
assert_eq!(NonZeroIsize::MIN.count_digits(), NonZeroI16::MIN.count_digits());
assert_eq!(NonZeroIsize::MAX.count_digits(), NonZeroI16::MAX.count_digits());
assert_eq!(usize::MIN.count_digits(), u16::MIN.count_digits());
assert_eq!(usize::MAX.count_digits(), u16::MAX.count_digits());
assert_eq!(NonZeroUsize::MIN.count_digits(), NonZeroU16::MIN.count_digits());
assert_eq!(NonZeroUsize::MAX.count_digits(), NonZeroU16::MAX.count_digits());
}
#[cfg(target_pointer_width = "8")] {
assert_eq!(isize::MIN.count_digits(), i8::MIN.count_digits());
assert_eq!(isize::MAX.count_digits(), i8::MAX.count_digits());
assert_eq!(NonZeroIsize::MIN.count_digits(), NonZeroI8::MIN.count_digits());
assert_eq!(NonZeroIsize::MAX.count_digits(), NonZeroI8::MAX.count_digits());
assert_eq!(usize::MIN.count_digits(), u8::MIN.count_digits());
assert_eq!(usize::MAX.count_digits(), u8::MAX.count_digits());
assert_eq!(NonZeroUsize::MIN.count_digits(), NonZeroU8::MIN.count_digits());
assert_eq!(NonZeroUsize::MAX.count_digits(), NonZeroU8::MAX.count_digits());
}
Sourcefn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
For all other radix values, counts digits according to the twos-complement representation.
§Examples
use count_digits::CountDigits;
for n in 0..100 {
assert!(std::panic::catch_unwind(|| n.count_digits_radix(0_u32)).is_err());
assert!(std::panic::catch_unwind(|| n.count_digits_radix(1_u32)).is_err());
assert_eq!(n.count_digits_radix(02_u32) as u32, n.count_bits());
assert_eq!(n.count_digits_radix(08_u32) as u32, n.count_octal_digits());
assert_eq!(n.count_digits_radix(16_u32) as u32, n.count_hex_digits());
assert_eq!(n.count_digits_radix(10_u32), n.count_digits());
}
Sourcefn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
For all other radix values, counts digits according to the twos-complement representation.
§Examples
use count_digits::CountDigits;
for n in 0..100 {
assert_eq!(n.checked_count_digits_radix(00_u32), None);
assert_eq!(n.checked_count_digits_radix(01_u32), None);
assert_eq!(n.checked_count_digits_radix(02_u32).unwrap() as u32, n.count_bits());
assert_eq!(n.checked_count_digits_radix(08_u32).unwrap() as u32, n.count_octal_digits());
assert_eq!(n.checked_count_digits_radix(16_u32).unwrap() as u32, n.count_hex_digits());
assert_eq!(n.checked_count_digits_radix(10_u32).unwrap(), n.count_digits());
}
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl CountDigits for i8
impl CountDigits for i8
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u8
Source§impl CountDigits for i16
impl CountDigits for i16
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u16
Source§impl CountDigits for i32
impl CountDigits for i32
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u32
Source§impl CountDigits for i64
impl CountDigits for i64
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u64
Source§impl CountDigits for i128
impl CountDigits for i128
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u128
Source§impl CountDigits for isize
impl CountDigits for isize
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = usize
Source§impl CountDigits for u8
impl CountDigits for u8
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u8
Source§impl CountDigits for u16
impl CountDigits for u16
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u16
Source§impl CountDigits for u32
impl CountDigits for u32
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u32
Source§impl CountDigits for u64
impl CountDigits for u64
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u64
Source§impl CountDigits for u128
impl CountDigits for u128
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u128
Source§impl CountDigits for usize
impl CountDigits for usize
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = usize
Source§impl CountDigits for NonZeroI8
impl CountDigits for NonZeroI8
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u8
Source§impl CountDigits for NonZeroI16
impl CountDigits for NonZeroI16
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u16
Source§impl CountDigits for NonZeroI32
impl CountDigits for NonZeroI32
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u32
Source§impl CountDigits for NonZeroI64
impl CountDigits for NonZeroI64
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u64
Source§impl CountDigits for NonZeroI128
impl CountDigits for NonZeroI128
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u128
Source§impl CountDigits for NonZeroIsize
impl CountDigits for NonZeroIsize
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = usize
Source§impl CountDigits for NonZeroU8
impl CountDigits for NonZeroU8
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u8
Source§impl CountDigits for NonZeroU16
impl CountDigits for NonZeroU16
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u16
Source§impl CountDigits for NonZeroU32
impl CountDigits for NonZeroU32
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u32
Source§impl CountDigits for NonZeroU64
impl CountDigits for NonZeroU64
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u64
Source§impl CountDigits for NonZeroU128
impl CountDigits for NonZeroU128
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = u128
Source§impl CountDigits for NonZeroUsize
impl CountDigits for NonZeroUsize
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Returns the count of bits in an integer.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Returns the count of octal digits in an integer.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Returns the count of hexadecimal digits in an integer.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Returns the count of decimal digits in an integer.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Returns the count of digits in an integer as interpreted with the given radix.
Panics if the provided radix is 0 or 1.
See checked_count_digits_radix() for a non-panicking version of this function.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Returns the count of digits in an integer as interpreted with the given radix.
Returns None if the provided radix is 0 or 1.
See count_digits_radix() for a panicking version of this function.
type Radix = usize
Source§impl<T: CountDigits> CountDigits for &T
impl<T: CountDigits> CountDigits for &T
Source§fn count_bits(self) -> u32
fn count_bits(self) -> u32
Calls count_bits() on the inner value.
Source§fn count_octal_digits(self) -> u32
fn count_octal_digits(self) -> u32
Calls count_octal_digits() on the inner value.
Source§fn count_digits(self) -> usize
fn count_digits(self) -> usize
Calls count_digits() on the inner value.
Source§fn count_hex_digits(self) -> u32
fn count_hex_digits(self) -> u32
Calls count_hex_digits() on the inner value.
Source§fn count_digits_radix(self, radix: Self::Radix) -> usize
fn count_digits_radix(self, radix: Self::Radix) -> usize
Calls count_digits_radix() on the inner value.
Source§fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
fn checked_count_digits_radix(self, radix: Self::Radix) -> Option<usize>
Calls checked_count_digits_radix() on the inner value.