Function array_bytes::hex2slice

source ·
pub fn hex2slice<H>(hex: H, slice: &mut [u8]) -> Result<&[u8]>where
    H: AsRef<str>,
Expand description

AsRef<str> to &[u8].

This function will modify the given slice’s source and return the revised result.

Return error while the length is an odd number, any byte out of radix, or mismatch in the slice size.

Examples

assert_eq!(
	array_bytes::hex2bytes("0x4c6f7665204a616e6520466f7265766572"),
	Ok(b"Love Jane Forever".to_vec())
);