summaryrefslogtreecommitdiffstats
path: root/tests/ui/btreemap/btreemap_dropck.rs
blob: c58727df30cae10d0c271932e32d77395fa247fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
}