We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7ad628a commit 3aef99fCopy full SHA for 3aef99f
text/0000-forget-marker-trait.md
@@ -188,7 +188,13 @@ Let's say that `Serial::read_exact` triggers a DMA transfer and returns a future
188
fn start(serial: &mut Serial) {
189
let mut buf = [0; 16];
190
191
- mem::forget(serial.read_exact(&mut buf));
+ let fut = Box::pin(serial.read_exact(&mut buf));
192
+
193
+ fut.poll(cx); // start dma transfer
194
195
+ // Memory of the future itself is still valid (inside the allocation),
196
+ // but the buffer lives outside of it and is not protected.
197
+ core::mem::forget(fut); // or `Box::leak`
198
}
199
200
fn corrupted() {
0 commit comments