@@ -908,10 +908,10 @@ declared, in an angle-bracket-enclosed, comma-separated list following
908
908
the function name.
909
909
910
910
~~~~ {.xfail-test}
911
- fn iter<T>(seq: ~ [T], f: fn(T)) {
911
+ fn iter<T>(seq: & [T], f: fn(T)) {
912
912
for seq.each |elt| { f(elt); }
913
913
}
914
- fn map<T, U>(seq: ~ [T], f: fn(T) -> U) -> ~[U] {
914
+ fn map<T, U>(seq: & [T], f: fn(T) -> U) -> ~[U] {
915
915
let mut acc = ~[];
916
916
for seq.each |elt| { acc.push(f(elt)); }
917
917
acc
@@ -1608,9 +1608,9 @@ indicate that the elements of the resulting vector may be mutated.
1608
1608
When no mutability is specified, the vector is immutable.
1609
1609
1610
1610
~~~~
1611
- ~ [1, 2, 3, 4];
1612
- ~ ["a", "b", "c", "d"];
1613
- ~ [mut 0u8, 0u8, 0u8, 0u8];
1611
+ [1, 2, 3, 4];
1612
+ ["a", "b", "c", "d"];
1613
+ [mut 0u8, 0u8, 0u8, 0u8];
1614
1614
~~~~
1615
1615
1616
1616
### Index expressions
@@ -1631,9 +1631,9 @@ task in a _failing state_.
1631
1631
~~~~
1632
1632
# do task::spawn_unlinked {
1633
1633
1634
- (~ [1, 2, 3, 4])[0];
1635
- (~ [mut 'x', 'y'])[1] = 'z';
1636
- (~ ["a", "b"])[10]; // fails
1634
+ ([1, 2, 3, 4])[0];
1635
+ ([mut 'x', 'y'])[1] = 'z';
1636
+ (["a", "b"])[10]; // fails
1637
1637
1638
1638
# }
1639
1639
~~~~
@@ -1770,10 +1770,10 @@ Any other cast is unsupported and will fail to compile.
1770
1770
An example of an ` as ` expression:
1771
1771
1772
1772
~~~~
1773
- # fn sum(v: ~ [float]) -> float { 0.0 }
1774
- # fn len(v: ~ [float]) -> int { 0 }
1773
+ # fn sum(v: & [float]) -> float { 0.0 }
1774
+ # fn len(v: & [float]) -> int { 0 }
1775
1775
1776
- fn avg(v: ~ [float]) -> float {
1776
+ fn avg(v: & [float]) -> float {
1777
1777
let sum: float = sum(v);
1778
1778
let sz: float = len(v) as float;
1779
1779
return sum / sz;
@@ -1800,8 +1800,8 @@ No allocation or destruction is entailed.
1800
1800
An example of three different move expressions:
1801
1801
1802
1802
~~~~~~~~
1803
- # let mut x = ~ [mut 0];
1804
- # let a = ~ [mut 0];
1803
+ # let mut x = & [mut 0];
1804
+ # let a = & [mut 0];
1805
1805
# let b = 0;
1806
1806
# let y = {mut z: 0};
1807
1807
# let c = 0;
@@ -1827,8 +1827,8 @@ No allocation or destruction is entailed.
1827
1827
An example of three different swap expressions:
1828
1828
1829
1829
~~~~~~~~
1830
- # let mut x = ~ [mut 0];
1831
- # let mut a = ~ [mut 0];
1830
+ # let mut x = & [mut 0];
1831
+ # let mut a = & [mut 0];
1832
1832
# let i = 0;
1833
1833
# let y = {mut z: 0};
1834
1834
# let b = {mut c: 0};
@@ -1929,11 +1929,11 @@ the unary copy operator is typically only used to cause an argument to a functio
1929
1929
An example of a copy expression:
1930
1930
1931
1931
~~~~
1932
- fn mutate(vec: ~ [mut int]) {
1932
+ fn mutate(vec: & [mut int]) {
1933
1933
vec[0] = 10;
1934
1934
}
1935
1935
1936
- let v = ~ [mut 1,2,3];
1936
+ let v = & [mut 1,2,3];
1937
1937
1938
1938
mutate(copy v); // Pass a copy
1939
1939
@@ -2716,7 +2716,7 @@ In this example, the trait `Printable` occurs as a type in both the type signatu
2716
2716
Within the body of an item that has type parameter declarations, the names of its type parameters are types:
2717
2717
2718
2718
~~~~~~~
2719
- fn map<A: Copy, B: Copy>(f: fn(A) -> B, xs: ~ [A]) -> ~[B] {
2719
+ fn map<A: Copy, B: Copy>(f: fn(A) -> B, xs: & [A]) -> ~[B] {
2720
2720
if xs.len() == 0 { return ~[]; }
2721
2721
let first: B = f(xs[0]);
2722
2722
let rest: ~[B] = map(f, xs.slice(1, xs.len()));
0 commit comments