struct PrintOnDrop<'a>(&'a str);
impl Drop for PrintOnDrop<'_> {
fn drop(&mut self) {
println!("printint: {}", self.0);
}
}
use std::collections::BTreeMap;
fn main() {
let s = String::from("Hello World!");
let map = BTreeMap::from_iter([((), PrintOnDrop(&s))]);
drop(s);
}
(playground)
@rustbot label T-libs, I-unsound
@rustbot claim
(playground)
@rustbot label T-libs, I-unsound
@rustbot claim