Skip to content

Commit a3c7d93

Browse files
committed
Get rid of basically all of the remaining old style vecs in tests.
1 parent 3bf5fef commit a3c7d93

File tree

6 files changed

+102
-87
lines changed

6 files changed

+102
-87
lines changed

doc/rust.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,12 +1006,12 @@ declared, in an angle-bracket-enclosed, comma-separated list following
10061006
the function name.
10071007

10081008
~~~~
1009-
fn iter<T>(seq: [T], f: fn(T)) {
1009+
fn iter<T>(seq: ~[T], f: fn(T)) {
10101010
for seq.each {|elt| f(elt); }
10111011
}
1012-
fn map<T, U>(seq: [T], f: fn(T) -> U) -> [U] {
1013-
let mut acc = [];
1014-
for seq.each {|elt| acc += [f(elt)]; }
1012+
fn map<T, U>(seq: ~[T], f: fn(T) -> U) -> ~[U] {
1013+
let mut acc = ~[];
1014+
for seq.each {|elt| vec::push(acc, f(elt)); }
10151015
acc
10161016
}
10171017
~~~~
@@ -1048,14 +1048,14 @@ same as any other Rust function, except that they are prepended with the
10481048
`extern` keyword.
10491049

10501050
~~~
1051-
extern fn new_vec() -> [int] { [] }
1051+
extern fn new_vec() -> ~[int] { ~[] }
10521052
~~~
10531053

10541054
Extern functions may not be called from Rust code, but their value
10551055
may be taken as an unsafe `u8` pointer.
10561056

10571057
~~~
1058-
# extern fn new_vec() -> [int] { [] }
1058+
# extern fn new_vec() -> ~[int] { ~[] }
10591059
let fptr: *u8 = new_vec;
10601060
~~~
10611061

@@ -1289,7 +1289,7 @@ specified, after the `impl` keyword.
12891289
~~~~
12901290
# iface seq<T> { }
12911291
1292-
impl <T> of seq<T> for [T] {
1292+
impl <T> of seq<T> for ~[T] {
12931293
/* ... */
12941294
}
12951295
impl of seq<bool> for u32 {
@@ -1615,9 +1615,9 @@ indicate that the elements of the resulting vector may be mutated.
16151615
When no mutability is specified, the vector is immutable.
16161616

16171617
~~~~
1618-
[1, 2, 3, 4];
1619-
["a", "b", "c", "d"];
1620-
[mut 0u8, 0u8, 0u8, 0u8];
1618+
~[1, 2, 3, 4];
1619+
~["a", "b", "c", "d"];
1620+
~[mut 0u8, 0u8, 0u8, 0u8];
16211621
~~~~
16221622

16231623
### Index expressions
@@ -1640,9 +1640,9 @@ task in a _failing state_.
16401640
# task::unsupervise(buildr);
16411641
# task::run(buildr) {||
16421642
1643-
[1, 2, 3, 4][0];
1644-
[mut 'x', 'y'][1] = 'z';
1645-
["a", "b"][10]; // fails
1643+
(~[1, 2, 3, 4])[0];
1644+
(~[mut 'x', 'y'])[1] = 'z';
1645+
(~["a", "b"])[10]; // fails
16461646
16471647
# }
16481648
~~~~
@@ -1760,10 +1760,10 @@ is unsupported and will fail to compile.
17601760
An example of an `as` expression:
17611761

17621762
~~~~
1763-
# fn sum(v: [float]) -> float { 0.0 }
1764-
# fn len(v: [float]) -> int { 0 }
1763+
# fn sum(v: ~[float]) -> float { 0.0 }
1764+
# fn len(v: ~[float]) -> int { 0 }
17651765
1766-
fn avg(v: [float]) -> float {
1766+
fn avg(v: ~[float]) -> float {
17671767
let sum: float = sum(v);
17681768
let sz: float = len(v) as float;
17691769
ret sum / sz;
@@ -1794,8 +1794,8 @@ expression. No allocation or destruction is entailed.
17941794
An example of three different move expressions:
17951795

17961796
~~~~~~~~
1797-
# let mut x = [mut 0];
1798-
# let a = [mut 0];
1797+
# let mut x = ~[mut 0];
1798+
# let a = ~[mut 0];
17991799
# let b = 0;
18001800
# let y = {mut z: 0};
18011801
# let c = 0;
@@ -1823,8 +1823,8 @@ expression. No allocation or destruction is entailed.
18231823
An example of three different swap expressions:
18241824

18251825
~~~~~~~~
1826-
# let mut x = [mut 0];
1827-
# let mut a = [mut 0];
1826+
# let mut x = ~[mut 0];
1827+
# let mut a = ~[mut 0];
18281828
# let i = 0;
18291829
# let y = {mut z: 0};
18301830
# let b = {mut c: 0};
@@ -1924,11 +1924,11 @@ argument to a function to be copied and passed by value.
19241924
An example of a copy expression:
19251925

19261926
~~~~
1927-
fn mutate(vec: [mut int]) {
1927+
fn mutate(vec: ~[mut int]) {
19281928
vec[0] = 10;
19291929
}
19301930
1931-
let v = [mut 1,2,3];
1931+
let v = ~[mut 1,2,3];
19321932
19331933
mutate(copy v); // Pass a copy
19341934
@@ -2067,7 +2067,7 @@ An example a for loop:
20672067
# fn bar(f: foo) { }
20682068
# let a = 0, b = 0, c = 0;
20692069
2070-
let v: [foo] = [a, b, c];
2070+
let v: ~[foo] = ~[a, b, c];
20712071
20722072
for v.each {|e|
20732073
bar(e);
@@ -2272,12 +2272,12 @@ the `note` to the internal logging diagnostic buffer.
22722272
An example of a `note` expression:
22732273

22742274
~~~~{.xfail-test}
2275-
fn read_file_lines(path: str) -> [str] {
2275+
fn read_file_lines(path: str) -> ~[str] {
22762276
note path;
22772277
let r: [str];
22782278
let f: file = open_read(path);
22792279
lines(f) {|s|
2280-
r += [s];
2280+
r += ~[s];
22812281
}
22822282
ret r;
22832283
}
@@ -2707,7 +2707,7 @@ the kind of its member type, as with other simple structural types.
27072707
An example of a vector type and its use:
27082708

27092709
~~~~
2710-
let v: [int] = [7, 5, 3];
2710+
let v: ~[int] = ~[7, 5, 3];
27112711
let i: int = v[2];
27122712
assert (i == 3);
27132713
~~~~
@@ -2719,8 +2719,8 @@ vector:
27192719

27202720

27212721
~~~~
2722-
let mut v: [int] = [1, 2, 3];
2723-
v += [4, 5, 6];
2722+
let mut v: ~[int] = ~[1, 2, 3];
2723+
v += ~[4, 5, 6];
27242724
~~~~
27252725

27262726
Normal vector concatenation causes the allocation of a fresh vector to hold

0 commit comments

Comments
 (0)