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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//! Providing macros to create bitmap convenently.
/// Create a `cbitmap::bitmap::Bitmap` by specifying the bit length and flags.
///
/// # Examples
/// Create a no-bit bitmap `cbitmap::bitmap::Bitmap<0>`:
/// ```
/// use cbitmap::bitmap::*;
/// let map = newmap!();
/// assert_eq!(map.bit_len(), 0);
/// ```
/// Create a default bitmap with all zero bit, specifying its
/// (expected) bit length. The actual length will be rounded up:
/// ```
/// use cbitmap::bitmap::*;
/// // must add ';' to indicate the argument is specifying length
/// let map = newmap!(;34);
/// // length will be rounded up to a multiple of 8:
/// assert_eq!(map.bit_len(), 40);
/// // you can also use const exprs:
/// let map = newmap!(;4096 * 8);
/// assert_eq!(map.byte_len(), 4096);
/// ```
/// Create a bitmap with flags. The flags muts be literal
/// integers, and are enumerated with `|`. The length is still
/// required to be specified:
/// ```
/// use cbitmap::bitmap::*;
/// let map = newmap!(1u8 | 0b100000u128; 8);
/// assert_eq!(map.test(0), true);
/// assert_eq!(map.test(5), true);
/// ```
/// You can also use variables, but you cannot use exprs:
/// ```
/// use cbitmap::bitmap::*;
/// let a = 1u64 << 34;
/// let b = 1u128 << 47;
/// let map = newmap!(a | b; 48);
/// assert_eq!(map.test(34), true);
/// assert_eq!(map.test(47), true);
/// // Not allowed!
/// // let map = newmap!((1 << 12) | (1 << 13); 14);
/// ```
/// # See also
/// [`crate::he_lang`]
;
=>
};
=>
};
=>
};
}
/// A wrapper of [`newmap`], which is a painted eggshell.
/// Create a bitmap with indexes instead of flags.
///
/// # Examples
/// It is allowed to use literal integers and variables:
/// ```
/// use cbitmap::bitmap::*;
/// let map = he_lang!(1 | 4; 5);
/// assert_eq!(map.bit_len(), 8);
/// assert_eq!(map.test(1), true);
/// assert_eq!(map.test(4), true);
/// ```
///
;
}