blob: e384aacb718451332b0f8f25df0044f7c0b6b440 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
struct Defer<'a> {
x: &'a [&'a str],
}
impl<'a> Drop for Defer<'a> {
fn drop(&mut self) {
unsafe {
println!("{:?}", self.x);
}
}
}
fn defer<'r>(x: &'r [&'r str]) -> Defer<'r> {
Defer {
x: x
}
}
fn main() {
let x = defer(&vec!["Goodbye", "world!"]); //~ ERROR temporary value dropped while borrowed
x.x[0];
}
|