1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use TokenStream;
use quote;
use ;
/// Decodes a hex string into a byte array at compile time
///
/// # Examples
///
/// ```rust
/// use hex_macro::hex;
/// const DATA: [u8; 11] = hex!("48656c6c6f20776f726c64");
/// assert_eq!(DATA, *b"Hello world");
/// ```
///
/// ```rust
/// use hex_macro::hex;
/// // With a '0x' prefix
/// const DATA: [u8; 11] = hex!("0x48656c6c6f20776f726c64");
/// assert_eq!(DATA, *b"Hello world");
/// ```
///
/// ```compile_fail
/// use hex_macro::hex;
/// const DATA: [u8; 10] = hex!("48656c6c6f20776f726c64"); // Wrong length byte array
/// ```
///
/// ```compile_fail
/// hex!("notvalidhexstring!"); // not a valid hex string
/// ```