pub fn n_of_digits(x: usize) -> usize
Expand description
Returns the number of digits of a number.
use mem_dbg::n_of_digits;
assert_eq!(n_of_digits(0), 1);
assert_eq!(n_of_digits(1), 1);
assert_eq!(n_of_digits(10), 2);
assert_eq!(n_of_digits(100), 3);
assert_eq!(n_of_digits(1000), 4);
assert_eq!(n_of_digits(10000), 5);
assert_eq!(n_of_digits(100000), 6);