initial commit
This commit is contained in:
4
exercises/04_traits/13_drop/Cargo.toml
Normal file
4
exercises/04_traits/13_drop/Cargo.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
[package]
|
||||
name = "drop"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
23
exercises/04_traits/13_drop/src/lib.rs
Normal file
23
exercises/04_traits/13_drop/src/lib.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
// TODO: implement a so-called "Drop bomb": a type that panics when dropped
|
||||
// unless a certain operation has been performed on it.
|
||||
// You can see the expected API in the tests below.
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_drop_bomb() {
|
||||
let bomb = DropBomb::new();
|
||||
// The bomb should panic when dropped
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_defused_drop_bomb() {
|
||||
let mut bomb = DropBomb::new();
|
||||
bomb.defuse();
|
||||
// The bomb should not panic when dropped
|
||||
// since it has been defused
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user