aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy/src/util/drop_bomb.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/embassy/src/util/drop_bomb.rs b/embassy/src/util/drop_bomb.rs
index b2b0684e5..7f0cc5d9c 100644
--- a/embassy/src/util/drop_bomb.rs
+++ b/embassy/src/util/drop_bomb.rs
@@ -1,6 +1,12 @@
1use crate::fmt::panic; 1use crate::fmt::panic;
2use core::mem; 2use core::mem;
3 3
4/// An explosive ordinance that panics if it is improperly disposed of.
5///
6/// This is to forbid dropping futures, when there is absolutely no other choice.
7///
8/// To correctly dispose of this device, call the [defuse](struct.DropBomb.html#method.defuse)
9/// method before this object is dropped.
4pub struct DropBomb { 10pub struct DropBomb {
5 _private: (), 11 _private: (),
6} 12}
@@ -9,7 +15,7 @@ impl DropBomb {
9 pub fn new() -> Self { 15 pub fn new() -> Self {
10 Self { _private: () } 16 Self { _private: () }
11 } 17 }
12 18 // Diffuses the bomb, rendering it safe to drop.
13 pub fn defuse(self) { 19 pub fn defuse(self) {
14 mem::forget(self) 20 mem::forget(self)
15 } 21 }