macro_rules! encode_uint_arr {
($func:ident, $num_ty:ty, $bits:literal) => { ... };
}
Expand description
Builds custom unsigned integer encode functions.
The macro’s 3 parameters are:
- The name of the function.
- The type to return.
- The number of encoded BITS to decode.
leb128fmt::encode_uint_arr!(encode_u33, u64, 33);
let result = encode_u33(0);
assert_eq!(Some(([0x00, 0x00, 0x00, 0x00, 0x00], 1)), result);
let result = encode_u33(8589934591);
assert_eq!(Some(([0xFF, 0xFF, 0xFF, 0xFF, 0x1F], 5)), result);