File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,13 +47,12 @@ of the definition, with automatically generated getters and setters for each fie
4747``` rust
4848use bitmap :: bitmap;
4949
50- bitmap! (
51- struct Player {
52- imposter : u1 ,
53- finished_tasks : u3 ,
54- kills : u3 ,
55- }
56- );
50+ #[bitmap]
51+ struct Player {
52+ imposter : u1 ,
53+ finished_tasks : u3 ,
54+ kills : u3 ,
55+ }
5756
5857let mut player = Player (0 );
5958assert_eq! (std :: mem :: size_of :: <Player >(), 1 );
@@ -87,13 +86,12 @@ the following traits are implemented:
8786``` rust
8887use bitmap :: bitmap;
8988
90- bitmap! (
91- struct Bits {
92- a : u32 ,
93- b : u16 ,
94- c : u16 ,
95- }
96- );
89+ #[bitmap]
90+ struct Bits {
91+ a : u32 ,
92+ b : u16 ,
93+ c : u16 ,
94+ }
9795
9896let bits = Bits (0 );
9997let underlying_u64 : u64 = bits . into ();
@@ -105,12 +103,11 @@ let underlying_u64 = *bits;
105103``` rust
106104use bitmap :: bitmap;
107105
108- bitmap! (
109- struct Bits {
110- flag : u1 ,
111- counter : u7 ,
112- }
113- );
106+ #[bitmap]
107+ struct Bits {
108+ flag : u1 ,
109+ counter : u7 ,
110+ }
114111```
115112
116113Each field must be in the form ` uN ` , where ` 1 <= N <= 128 ` .
@@ -131,12 +128,11 @@ This means the first declared field is stored in the highest bits of the underly
131128``` rust
132129use bitmap :: bitmap;
133130
134- bitmap! (
135- struct Bits {
136- a : u8 ,
137- b : u8 ,
138- }
139- );
131+ #[bitmap]
132+ struct Bits {
133+ a : u8 ,
134+ b : u8 ,
135+ }
140136
141137let mut bits = Bits (0 );
142138bits . set_a (0xaa )
@@ -154,11 +150,10 @@ field will take up 64 bits of space.
154150``` rust
155151use bitmap :: bitmap;
156152
157- bitmap! (
158- struct Bits {
159- field : u33 ,
160- }
161- );
153+ #[bitmap]
154+ struct Bits {
155+ field : u33 ,
156+ }
162157
163158assert_eq! (core :: mem :: size_of :: <Bits >(), 8 );
164159```
You can’t perform that action at this time.
0 commit comments