Macro bdk_chain::bitcoin::hashes::hex::display::fmt_hex_exact

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 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.

Note that the bytes parameter is IntoIterator this means that if you would like to do some manipulation to the byte array before formatting then you can. For example bytes.iter().rev() to print the array backwards.

§Parameters

  • $formatter - a fmt::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 type Case 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.