We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 83a8869 commit d8026d7Copy full SHA for d8026d7
tests/zeroing.rs
@@ -0,0 +1,32 @@
1
+use std::{marker::PhantomPinned, ptr::addr_of_mut};
2
+
3
+use pinned_init::*;
4
5
+const MARKS: usize = 64;
6
7
+#[pin_data]
8
+#[derive(Zeroable)]
9
+pub struct Foo {
10
+ buf: [u8; 1024 * 1024],
11
+ marks: [*mut u8; MARKS],
12
+ pos: usize,
13
+ #[pin]
14
+ _pin: PhantomPinned,
15
+}
16
17
+impl Foo {
18
+ pub fn new() -> impl PinInit<Self> {
19
+ pin_init!(&this in Self {
20
+ marks: {
21
+ let ptr = this.as_ptr();
22
+ let ptr = unsafe { addr_of_mut!((*ptr).buf)}.cast::<u8>();
23
+ [ptr; MARKS]},
24
+ ..Zeroable::zeroed()
25
+ })
26
+ }
27
28
29
+#[test]
30
+fn test() {
31
+ let _ = Box::pin_init(Foo::new()).unwrap();
32
0 commit comments