rust/src/test/run-pass/alt-pattern-drop.rs
2011-09-02 15:13:41 -07:00

33 lines
490 B
Rust

// -*- rust -*-
use std;
import std::dbg;
tag t { make_t(@int); clam; }
fn foo(s: @int) {
let count = dbg::refcount(s);
let x: t = make_t(s); // ref up
alt x {
make_t(y) {
log y; // ref up then down
}
_ { log "?"; fail; }
}
log dbg::refcount(s);
assert (dbg::refcount(s) == count + 1u);
}
fn main() {
let s: @int = @0; // ref up
foo(s); // ref up then down
log dbg::refcount(s);
assert (dbg::refcount(s) == 1u);
}