aboutsummaryrefslogtreecommitdiff
path: root/embassy-hal-internal/src/drop.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-hal-internal/src/drop.rs')
-rw-r--r--embassy-hal-internal/src/drop.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/embassy-hal-internal/src/drop.rs b/embassy-hal-internal/src/drop.rs
index 7cd16aaec..8383fcc16 100644
--- a/embassy-hal-internal/src/drop.rs
+++ b/embassy-hal-internal/src/drop.rs
@@ -1,16 +1,20 @@
1//! Types for controlling when drop is invoked.
1use core::mem; 2use core::mem;
2use core::mem::MaybeUninit; 3use core::mem::MaybeUninit;
3 4
4#[must_use = "to delay the drop handler invokation to the end of the scope"] 5/// A type to delay the drop handler invocation.
6#[must_use = "to delay the drop handler invocation to the end of the scope"]
5pub struct OnDrop<F: FnOnce()> { 7pub struct OnDrop<F: FnOnce()> {
6 f: MaybeUninit<F>, 8 f: MaybeUninit<F>,
7} 9}
8 10
9impl<F: FnOnce()> OnDrop<F> { 11impl<F: FnOnce()> OnDrop<F> {
12 /// Create a new instance.
10 pub fn new(f: F) -> Self { 13 pub fn new(f: F) -> Self {
11 Self { f: MaybeUninit::new(f) } 14 Self { f: MaybeUninit::new(f) }
12 } 15 }
13 16
17 /// Prevent drop handler from running.
14 pub fn defuse(self) { 18 pub fn defuse(self) {
15 mem::forget(self) 19 mem::forget(self)
16 } 20 }
@@ -34,6 +38,7 @@ pub struct DropBomb {
34} 38}
35 39
36impl DropBomb { 40impl DropBomb {
41 /// Create a new instance.
37 pub fn new() -> Self { 42 pub fn new() -> Self {
38 Self { _private: () } 43 Self { _private: () }
39 } 44 }