blob: 1447b48d515d51ea5a08209581e2800a33b889bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// -*- 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);
}
|