2013-05-10 16:12:19 +10:00
|
|
|
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
2012-12-10 17:32:48 -08:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2012-08-20 20:05:00 -04:00
|
|
|
struct X {
|
2012-09-07 14:50:47 -07:00
|
|
|
x: ~str,
|
2012-11-14 01:22:37 -05:00
|
|
|
}
|
|
|
|
|
2013-02-14 11:47:00 -08:00
|
|
|
impl Drop for X {
|
2012-11-28 15:42:16 -08:00
|
|
|
fn finalize(&self) {
|
2012-08-20 20:05:00 -04:00
|
|
|
error!("value: %s", self.x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = X { x: ~"hello" };
|
2013-05-10 16:12:19 +10:00
|
|
|
|
|
|
|
match x {
|
|
|
|
X { x: y } => error!("contents: %s", y)
|
2013-05-22 06:54:35 -04:00
|
|
|
//~^ ERROR cannot move out of type `X`, which defines the `Drop` trait
|
2013-05-10 16:12:19 +10:00
|
|
|
}
|
2012-08-20 20:05:00 -04:00
|
|
|
}
|