Macro usize_to_str

Source
macro_rules! usize_to_str {
    ( $n:expr; 1 ) => { ... };
    ( $n:expr; 2 ) => { ... };
    ( $n:expr; $len:expr ) => { ... };
    ( $n:expr; $len:expr, bit_128 ) => { ... };
}
Expand description

Formats a positive number into a StackStr<N>. The parameters required are the number that must be converted and the length of N, namely the number of digits of the given number, separated by a semicolon. In case the number has less digits than the specified length, it will have trailing zeros, represented as their utf-8 value: 48. In case the length is less than required, it will result in undefined behavior.

§Examples

 
assert_eq!("291", usize_to_str!(291; 3).str());
assert_eq!("0291", usize_to_str!(291; 4).str());
 

This function by default accepts values up to u64. If values up to u128 are needed, as a third parameter specify bit_128.

§Examples

 
assert_eq!("000123714384710312239874874388", usize_to_str!(123714384710312239874874388; 30, bit_128).str());