Turn old drop blocks into Drop traits

This commit is contained in:
Ben Striegel 2013-02-27 19:13:53 -05:00
parent 33e7a1f087
commit 43d43adf6b
22 changed files with 117 additions and 29 deletions

View file

@ -12,7 +12,10 @@
pub struct S {
x: int,
drop {
}
impl Drop for S {
fn finalize(&self) {
io::println("goodbye");
}
}

View file

@ -1,6 +1,9 @@
struct S {
x: int,
drop {}
}
impl Drop for S {
fn finalize(&self) {}
}
impl S {

View file

@ -21,7 +21,10 @@ fn recurse() {
struct r {
recursed: *mut bool,
drop {
}
impl Drop for r {
fn finalize(&self) {
unsafe {
if !*(self.recursed) {
*(self.recursed) = true;

View file

@ -12,7 +12,10 @@
struct r {
i: int,
drop { fail!(~"squirrel") }
}
impl Drop for r {
fn finalize(&self) { fail!(~"squirrel") }
}
fn r(i: int) -> r { r { i: i } }

View file

@ -13,7 +13,10 @@
struct r {
i: int,
drop { fail!(~"wombat") }
}
impl Drop for r {
fn finalize(&self) { fail!(~"wombat") }
}
fn r(i: int) -> r { r { i: i } }

View file

@ -54,7 +54,10 @@ struct AsciiArt
// This struct can be quite large so we'll disable copying: developers need
// to either pass these structs around via borrowed pointers or move them.
drop {}
}
impl Drop for AsciiArt {
fn finalize(&self) {}
}
// It's common to define a constructor sort of function to create struct instances.