try_hex

Macro try_hex 

Source
macro_rules! try_hex {
    ($x:literal) => { ... };
}
Expand description

Macro for creating a ByteArray from a hexadecimal string literal (without 0x prefix).

§CAVEAT

This macro always interprets the input as hexadecimal. It does not perform UTF-8 conversion. If you need automatic format detection with UTF-8 fallback, use try_bytes! instead.

§Examples

use byte_array_ops::try_hex;

let hex = try_hex!("deadbeef").unwrap();
assert_eq!(hex.as_bytes(), [0xde, 0xad, 0xbe, 0xef]);