@@ -886,8 +886,8 @@ fn main() {
886
886
// Equivalent to 'std::iter::range_step(0, 10, 2);'
887
887
range_step(0, 10, 2);
888
888
889
- // Equivalent to 'foo(~ [std::option::Some(1.0), std::option::None]);'
890
- foo(~ [Some(1.0), None]);
889
+ // Equivalent to 'foo(vec! [std::option::Some(1.0), std::option::None]);'
890
+ foo(vec! [Some(1.0), None]);
891
891
}
892
892
~~~~
893
893
@@ -995,8 +995,8 @@ the function name.
995
995
fn iter<T>(seq: &[T], f: |T|) {
996
996
for elt in seq.iter() { f(elt); }
997
997
}
998
- fn map<T, U>(seq: &[T], f: |T| -> U) -> ~[U] {
999
- let mut acc = ~ [];
998
+ fn map<T, U>(seq: &[T], f: |T| -> U) -> Vec<U> {
999
+ let mut acc = vec! [];
1000
1000
for elt in seq.iter() { acc.push(f(elt)); }
1001
1001
acc
1002
1002
}
@@ -1159,19 +1159,19 @@ except that they have the `extern` modifier.
1159
1159
1160
1160
~~~~
1161
1161
// Declares an extern fn, the ABI defaults to "C"
1162
- extern fn new_vec () -> ~[ int] { ~[] }
1162
+ extern fn new_int () -> int { 0 }
1163
1163
1164
1164
// Declares an extern fn with "stdcall" ABI
1165
- extern "stdcall" fn new_vec_stdcall () -> ~[ int] { ~[] }
1165
+ extern "stdcall" fn new_int_stdcall () -> int { 0 }
1166
1166
~~~~
1167
1167
1168
1168
Unlike normal functions, extern fns have an ` extern "ABI" fn() ` .
1169
1169
This is the same type as the functions declared in an extern
1170
1170
block.
1171
1171
1172
1172
~~~~
1173
- # extern fn new_vec () -> ~[ int] { ~[] }
1174
- let fptr: extern "C" fn() -> ~[ int] = new_vec ;
1173
+ # extern fn new_int () -> int { 0 }
1174
+ let fptr: extern "C" fn() -> int = new_int ;
1175
1175
~~~~
1176
1176
1177
1177
Extern functions may be called directly from Rust code as Rust uses large,
@@ -1509,7 +1509,7 @@ Implementation parameters are written after the `impl` keyword.
1509
1509
1510
1510
~~~~
1511
1511
# trait Seq<T> { }
1512
- impl<T> Seq<T> for ~[T] {
1512
+ impl<T> Seq<T> for Vec<T> {
1513
1513
/* ... */
1514
1514
}
1515
1515
impl Seq<bool> for u32 {
@@ -3347,7 +3347,7 @@ Such a definite-sized vector type is a first-class type, since its size is known
3347
3347
A vector without such a size is said to be of _ indefinite_ size,
3348
3348
and is therefore not a _ first-class_ type.
3349
3349
An indefinite-size vector can only be instantiated through a pointer type,
3350
- such as ` &[T] ` or ` ~[T] ` .
3350
+ such as ` &[T] ` or ` Vec<T> ` .
3351
3351
The kind of a vector type depends on the kind of its element type,
3352
3352
as with other simple structural types.
3353
3353
0 commit comments