Turn old drop blocks into Drop traits
This commit is contained in:
parent
33e7a1f087
commit
43d43adf6b
22 changed files with 117 additions and 29 deletions
|
|
@ -12,7 +12,10 @@
|
|||
|
||||
pub struct S {
|
||||
x: int,
|
||||
drop {
|
||||
}
|
||||
|
||||
impl Drop for S {
|
||||
fn finalize(&self) {
|
||||
io::println("goodbye");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
struct S {
|
||||
x: int,
|
||||
drop {}
|
||||
}
|
||||
|
||||
impl Drop for S {
|
||||
fn finalize(&self) {}
|
||||
}
|
||||
|
||||
impl S {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 } }
|
||||
|
|
|
|||
|
|
@ -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 } }
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue