Macro bitcoin_private::fmt_hex_exact
source · macro_rules! fmt_hex_exact { ($formatter:expr, $len:expr, $bytes:expr, $case:expr) => { ... }; }
Expand description
Format known-length array as hex.
This supports all formatting options of formatter and may be faster than calling
display_as_hex()
on an arbitrary &[u8]
. Note that the implementation intentionally keeps
leading zeros even when not requested. This is designed to display values such as hashes and
keys and removing leading zeros would be confusing.
Parameters
$formatter
- afmt::Formatter
.$len
known length of$bytes
, must be a const expression.$bytes
- bytes to be encoded, most likely a reference to an array.$case
- value of typeCase
determining whether to format as lower or upper case.
Panics
This macro panics if $len
is not equal to $bytes.len()
. It also fails to compile if $len
is more than half of usize::MAX
.