pub fn decode_to_slice(
value: &str,
bits: &mut [u8],
) -> Result<(), DecodeHexError>Expand description
Decode a hex string prefixed with 0x into a mutable bytes slice.
Both, upper and lower case characters are valid in the input string and can
even be mixed (e.g. 0xf9b4ca, 0xF9B4CA and 0xf9B4Ca are all valid strings).
ยงExample
use dcl_crypto::account::{decode_to_slice, DecodeHexError};
let mut bytes = [0u8; 4];
assert_eq!(decode_to_slice("0x6b697769", &mut bytes as &mut [u8]), Ok(()));
assert_eq!(&bytes, b"kiwi");