aboutsummaryrefslogtreecommitdiff
path: root/src/drop_bomb.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/drop_bomb.rs')
-rw-r--r--src/drop_bomb.rs21
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 @@
1use std::borrow::Cow;
2
3pub struct DropBomb {
4 msg: Cow<'static, str>,
5 defused: bool,
6}
7
8impl 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
15impl Drop for DropBomb {
16 fn drop(&mut self) {
17 if !self.defused && !::std::thread::panicking() {
18 panic!("{}", self.msg)
19 }
20 }
21}