2012-08-20 19:05:00 -05:00
|
|
|
struct X {
|
2012-09-07 16:50:47 -05:00
|
|
|
x: ~str,
|
2012-11-14 00:22:37 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impl X : Drop {
|
|
|
|
fn finalize() {
|
2012-08-20 19:05:00 -05:00
|
|
|
error!("value: %s", self.x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn unwrap(+x: X) -> ~str {
|
|
|
|
let X { x: y } = x; //~ ERROR deconstructing struct not allowed in pattern
|
|
|
|
y
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = X { x: ~"hello" };
|
|
|
|
let y = unwrap(x);
|
|
|
|
error!("contents: %s", y);
|
|
|
|
}
|