2010-08-27 15:27:28 -05:00
|
|
|
// -*- rust -*-
|
|
|
|
|
|
|
|
use std;
|
|
|
|
import std._str;
|
|
|
|
|
2010-09-09 17:59:29 -05:00
|
|
|
tag t {
|
|
|
|
make_t(str);
|
2010-09-21 01:56:43 -05:00
|
|
|
clam;
|
2010-09-09 17:59:29 -05:00
|
|
|
}
|
2010-08-27 15:27:28 -05:00
|
|
|
|
2010-08-27 15:48:45 -05:00
|
|
|
fn foo(str s) {
|
2010-08-27 15:27:28 -05:00
|
|
|
let t x = make_t(s); // ref up
|
|
|
|
|
|
|
|
alt (x) {
|
2010-09-21 01:56:43 -05:00
|
|
|
case (make_t(?y)) { log y; } // ref up then down
|
2010-08-27 15:29:48 -05:00
|
|
|
case (_) { log "?"; fail; }
|
2010-08-27 15:27:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
log _str.refcount(s);
|
2010-08-27 15:48:45 -05:00
|
|
|
check (_str.refcount(s) == 3u);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let str s = "hi"; // ref up
|
|
|
|
foo(s); // ref up then down
|
|
|
|
log _str.refcount(s);
|
|
|
|
check (_str.refcount(s) == 1u);
|
2010-08-27 15:27:28 -05:00
|
|
|
}
|