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
#![deny(missing_docs)]
pub use buffering_nocopy_macro::NoCopy;
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_proc_macro() {
#[derive(Copy, Clone, NoCopy)]
#[repr(C)]
#[nocopy_macro(name = "TestBufferThing")]
pub struct Test {
test: u8,
}
let mut tb = TestBufferThing::new_buffer([0]);
tb.set_test(5);
assert_eq!(tb.as_buffer(), [5]);
#[derive(Copy, Clone, NoCopy)]
#[repr(C)]
#[nocopy_macro(name = "TestBufferThingTwo", endian = "big")]
pub struct TestTwo {
test: u16,
}
let tb = TestBufferThingTwo::new_buffer([0, 5]);
assert_eq!(tb.get_test(), 5);
#[derive(Copy, Clone, NoCopy)]
#[repr(C)]
#[nocopy_macro(name = "TestBufferThingThree", endian = "little")]
pub struct TestThree {
test: u16,
}
let tb = TestBufferThingThree::new_buffer([5, 0]);
assert_eq!(tb.get_test(), 5);
}
}