Function array_bytes::hex_try_into[][src]

pub fn hex_try_into<H, T, const N: usize>(hex: H) -> ArrayBytesResult<T> where
    H: AsRef<str>,
    T: From<[u8; N]>, 
Expand description

Try to convert Hex to a type directly

Examples

#[derive(Debug, PartialEq)]
struct LJF([u8; 17]);
impl From<[u8; 17]> for LJF {
	fn from(array: [u8; 17]) -> Self {
		Self(array)
	}
}

assert_eq!(
	array_bytes::hex_try_into::<_, LJF, 17>("0x4c6f7665204a616e6520466f7265766572").unwrap(),
	LJF(*b"Love Jane Forever")
);