diff options
Diffstat (limited to 'src/drop_bomb.rs')
-rw-r--r-- | src/drop_bomb.rs | 21 |
1 files changed, 0 insertions, 21 deletions
diff --git a/src/drop_bomb.rs b/src/drop_bomb.rs deleted file mode 100644 index 750904a01..000000000 --- a/src/drop_bomb.rs +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | use std::borrow::Cow; | ||
2 | |||
3 | pub struct DropBomb { | ||
4 | msg: Cow<'static, str>, | ||
5 | defused: bool, | ||
6 | } | ||
7 | |||
8 | impl DropBomb { | ||
9 | pub fn new(msg: impl Into<Cow<'static, str>>) -> DropBomb { | ||
10 | DropBomb { msg: msg.into(), defused: false } | ||
11 | } | ||
12 | pub fn defuse(&mut self) { self.defused = true } | ||
13 | } | ||
14 | |||
15 | impl Drop for DropBomb { | ||
16 | fn drop(&mut self) { | ||
17 | if !self.defused && !::std::thread::panicking() { | ||
18 | panic!("{}", self.msg) | ||
19 | } | ||
20 | } | ||
21 | } | ||