From da59112e86d43efc070ae09197930023552638ca Mon Sep 17 00:00:00 2001 From: Joshua Salzedo Date: Wed, 24 Mar 2021 12:36:02 -0700 Subject: [PATCH] Document the DropBomb --- embassy/src/util/drop_bomb.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/embassy/src/util/drop_bomb.rs b/embassy/src/util/drop_bomb.rs index b2b0684e..7f0cc5d9 100644 --- a/embassy/src/util/drop_bomb.rs +++ b/embassy/src/util/drop_bomb.rs @@ -1,6 +1,12 @@ use crate::fmt::panic; use core::mem; +/// An explosive ordinance that panics if it is improperly disposed of. +/// +/// This is to forbid dropping futures, when there is absolutely no other choice. +/// +/// To correctly dispose of this device, call the [defuse](struct.DropBomb.html#method.defuse) +/// method before this object is dropped. pub struct DropBomb { _private: (), } @@ -9,7 +15,7 @@ impl DropBomb { pub fn new() -> Self { Self { _private: () } } - + // Diffuses the bomb, rendering it safe to drop. pub fn defuse(self) { mem::forget(self) }