rust/tests/ui/btreemap/btreemap_dropck.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
390 B
Rust
Raw Normal View History

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
}