3
3
// -*- rust -*-
4
4
use std;
5
5
import std:: str;
6
- import std:: vec;
7
-
6
+ import std:: ivec;
8
7
9
8
// FIXME: import std::dbg::const_refcount. Currently
10
9
// cross-crate const references don't work.
11
10
const const_refcount: uint = 0x7bad_face_ u;
12
11
13
12
fn fast_growth ( ) {
14
- let v: vec [ int ] = [ 1 , 2 , 3 , 4 , 5 ] ;
15
- v += [ 6 , 7 , 8 , 9 , 0 ] ;
13
+ let v: [ int ] = ~ [ 1 , 2 , 3 , 4 , 5 ] ;
14
+ v += ~ [ 6 , 7 , 8 , 9 , 0 ] ;
16
15
log v. ( 9 ) ;
17
16
assert ( v. ( 0 ) == 1 ) ;
18
17
assert ( v. ( 7 ) == 8 ) ;
19
18
assert ( v. ( 9 ) == 0 ) ;
20
19
}
21
20
22
21
fn slow_growth ( ) {
23
- let v: vec [ int ] = [ ] ;
24
- let u: vec [ int ] = v;
25
- v += [ 17 ] ;
22
+ let v: [ int ] = ~ [ ] ;
23
+ let u: [ int ] = v;
24
+ v += ~ [ 17 ] ;
26
25
log v. ( 0 ) ;
27
26
assert ( v. ( 0 ) == 17 ) ;
28
27
}
29
28
30
29
fn slow_growth2_helper ( s : str ) { // ref up: s
31
30
32
- obj acc ( mutable v: vec [ str] ) {
33
- fn add ( s : & str ) { v += [ s] ; }
31
+ obj acc ( mutable v: [ str] ) {
32
+ fn add ( s : & str ) { v += ~ [ s] ; }
34
33
}
35
34
let ss: str = s; // ref up: s
36
35
@@ -47,26 +46,21 @@ fn slow_growth2_helper(s: str) { // ref up: s
47
46
* mumble, the existing str in the originally- shared vec.
48
47
*/
49
48
50
- let v: vec [ str ] = [ mumble] ; // ref up: v, mumble
49
+ let v: [ str ] = ~ [ mumble] ; // ref up: mumble
51
50
52
- log vec:: refcount[ str] ( v) ;
53
- let a: acc = acc ( v) ; // ref up: a, v
51
+ let a: acc = acc ( v) ;
54
52
55
- log vec:: refcount[ str] ( v) ;
56
- assert ( vec:: refcount[ str] ( v) == 2 u) ;
57
- a. add ( s) ; // ref up: mumble, s. ref down: v
53
+ a. add ( s) ; // ref up: mumble, s
58
54
59
- log vec:: refcount[ str] ( v) ;
60
55
log str:: refcount ( s) ;
61
56
log str:: refcount ( mumble) ;
62
- assert ( vec:: refcount[ str] ( v) == 1 u) ;
63
57
assert ( str:: refcount ( s) == const_refcount) ;
64
58
assert ( str:: refcount ( mumble) == const_refcount) ;
65
59
log v. ( 0 ) ;
66
- log vec :: len[ str] ( v) ;
60
+ log ivec :: len[ str] ( v) ;
67
61
assert ( str:: eq ( v. ( 0 ) , mumble) ) ;
68
- assert ( vec :: len[ str] ( v) == 1 u) ;
69
- } // ref down: a, mumble, s, v
62
+ assert ( ivec :: len[ str] ( v) == 1 u) ;
63
+ } // ref down: mumble, s,
70
64
71
65
log str:: refcount ( s) ;
72
66
log str:: refcount ( mumble) ;
0 commit comments