[][src]Function delog::hex::HexStr

pub fn HexStr<T: ?Sized, U: Unsigned, S: Separator>(
    value: &T
) -> HexStr<'_, T, U, S>

Explicitly construct a newtype to format with.

The first generic parameter specifies the block size in bytes, the second parameter the separator string.

This function is just here for documentation of what the hex_str! macro does internally (using the undocumented typeint! and typesep! macros).

use delog::hex::{HexStr, Separator, Unsigned};

// typeint!(U3, 3);
struct U3 {}
impl Unsigned for U3 {
    const N: usize = 3;
}

// typesep!(Pipe, "|");
struct Pipe {}
impl Separator for Pipe {
    const SEPARATOR: &'static str  = "|";
}

let four_bytes = &[7u8, 0xA1, 255, 0xC7];
let hex_str = HexStr::<_, U3, Pipe>(four_bytes);

assert_eq!(format!("{}", hex_str), "07A1FF|C7");