Macro delog::hex_str

source ·
macro_rules! hex_str {
    ($array:expr) => { ... };
    ($array:expr, sep: $separator:expr) => { ... };
    ($array:expr, $n:tt) => { ... };
    ($array:expr, $n:tt, sep: $separator:expr) => { ... };
}
Expand description

Compactly format byte arrays and slices as hexadecimals.

The second parameter refers to the number of bytes in a block (separated by spaces).

use delog::hex_str;
let four_bytes = &[7u8, 0xA1, 255, 0xC7];
assert_eq!(format!("{:x}", hex_str!(four_bytes)), "07 a1 ff c7");
assert_eq!(format!("{}", hex_str!(four_bytes, 2)), "07A1 FFC7");
assert_eq!(format!("{}", hex_str!(four_bytes, 2, sep: "|")), "07A1|FFC7");
assert_eq!(format!("{}", hex_str!(four_bytes, 3)), "07A1FF C7");