blob: c58727df30cae10d0c271932e32d77395fa247fa [file] [log] [blame]
struct PrintOnDrop<'a>(&'a str);
impl Drop for PrintOnDrop<'_> {
fn drop(&mut self) {
println!("printint: {}", self.0);
}
}
use std::collections::BTreeMap;
use std::iter::FromIterator;
fn main() {
let s = String::from("Hello World!");
let _map = BTreeMap::from_iter([((), PrintOnDrop(&s))]);
drop(s); //~ ERROR cannot move out of `s` because it is borrowed
}