Function hex::decode_to_slice[][src]

pub fn decode_to_slice<T: AsRef<[u8]>>(
    data: T,
    out: &mut [u8]
) -> Result<(), FromHexError>

Decode a hex string into a mutable bytes slice.

Both, upper and lower case characters are valid in the input string and can even be mixed (e.g. f9b4ca, F9B4CA and f9B4Ca are all valid strings).

Example

let mut bytes = [0u8; 4];
assert_eq!(hex::decode_to_slice("6b697769", &mut bytes as &mut [u8]), Ok(()));
assert_eq!(&bytes, b"kiwi");