@@ -206,12 +206,12 @@ pub pure fn build_sized_opt<A>(size: Option<uint>,
206
206
}
207
207
208
208
/// Produces a mut vector from an immutable vector.
209
- pub pure fn cast_to_mut < T > ( v : ~[ T ] ) -> ~[ T ] {
209
+ pub pure fn cast_to_mut < T > ( v : ~[ T ] ) -> ~[ mut T ] {
210
210
unsafe { :: cast:: transmute ( v) }
211
211
}
212
212
213
213
/// Produces an immutable vector from a mut vector.
214
- pub pure fn cast_from_mut < T > ( v : ~[ T ] ) -> ~[ T ] {
214
+ pub pure fn cast_from_mut < T > ( v : ~[ mut T ] ) -> ~[ T ] {
215
215
unsafe { :: cast:: transmute ( v) }
216
216
}
217
217
@@ -562,7 +562,7 @@ pub fn consume<T>(v: ~[T], f: fn(uint, v: T)) {
562
562
}
563
563
}
564
564
565
- pub fn consume_mut < T > ( v : ~[ T ] , f : fn ( uint , v : T ) ) {
565
+ pub fn consume_mut < T > ( v : ~[ mut T ] , f : fn ( uint , v : T ) ) {
566
566
consume ( vec:: cast_from_mut ( v) , f)
567
567
}
568
568
@@ -731,7 +731,7 @@ pub pure fn append_one<T>(lhs: ~[T], x: T) -> ~[T] {
731
731
}
732
732
733
733
#[ inline( always) ]
734
- pub pure fn append_mut < T : Copy > ( lhs : ~[ T ] , rhs : & [ const T ] ) -> ~[ T ] {
734
+ pub pure fn append_mut < T : Copy > ( lhs : ~[ mut T ] , rhs : & [ const T ] ) -> ~[ mut T ] {
735
735
cast_to_mut ( append ( cast_from_mut ( lhs) , rhs) )
736
736
}
737
737
@@ -1263,12 +1263,12 @@ pub pure fn zip<T, U>(v: ~[T], u: ~[U]) -> ~[(T, U)] {
1263
1263
* * a - The index of the first element
1264
1264
* * b - The index of the second element
1265
1265
*/
1266
- pub fn swap < T > ( v : & mut [ T ] , a : uint , b : uint ) {
1266
+ pub fn swap < T > ( v : & [ mut T ] , a : uint , b : uint ) {
1267
1267
v[ a] <-> v[ b] ;
1268
1268
}
1269
1269
1270
1270
/// Reverse the order of elements in a vector, in place
1271
- pub fn reverse < T > ( v : & mut [ T ] ) {
1271
+ pub fn reverse < T > ( v : & [ mut T ] ) {
1272
1272
let mut i: uint = 0 ;
1273
1273
let ln = len :: < T > ( v) ;
1274
1274
while i < ln / 2 { v[ i] <-> v[ ln - i - 1 ] ; i += 1 ; }
@@ -1349,7 +1349,7 @@ pub pure fn each<T>(v: &r/[T], f: fn(&r/T) -> bool) {
1349
1349
/// a vector with mutable contents and you would like
1350
1350
/// to mutate the contents as you iterate.
1351
1351
#[ inline( always) ]
1352
- pub fn each_mut < T > ( v : & mut [ T ] , f : fn ( elem : & mut T ) -> bool ) {
1352
+ pub fn each_mut < T > ( v : & [ mut T ] , f : fn ( elem : & mut T ) -> bool ) {
1353
1353
let mut i = 0 ;
1354
1354
let n = v. len ( ) ;
1355
1355
while i < n {
@@ -1519,7 +1519,7 @@ pub pure fn as_const_buf<T,U>(s: &[const T],
1519
1519
1520
1520
/// Similar to `as_imm_buf` but passing a `*mut T`
1521
1521
#[ inline( always) ]
1522
- pub pure fn as_mut_buf < T , U > ( s : & mut [ T ] ,
1522
+ pub pure fn as_mut_buf < T , U > ( s : & [ mut T ] ,
1523
1523
f : fn ( * mut T , uint ) -> U ) -> U {
1524
1524
1525
1525
unsafe {
@@ -1640,9 +1640,9 @@ pub mod traits {
1640
1640
}
1641
1641
}
1642
1642
1643
- impl < T : Copy > ~[ T ] : Add < & [ const T ] , ~[ T ] > {
1643
+ impl < T : Copy > ~[ mut T ] : Add < & [ const T ] , ~[ mut T ] > {
1644
1644
#[ inline( always) ]
1645
- pure fn add ( & self , rhs : & & self /[ const T ] ) -> ~[ T ] {
1645
+ pure fn add ( & self , rhs : & & self /[ const T ] ) -> ~[ mut T ] {
1646
1646
append_mut ( copy * self , ( * rhs) )
1647
1647
}
1648
1648
}
@@ -2066,7 +2066,7 @@ pub mod raw {
2066
2066
2067
2067
/** see `to_ptr()` */
2068
2068
#[ inline( always) ]
2069
- pub unsafe fn to_mut_ptr < T > ( v : & mut [ T ] ) -> * mut T {
2069
+ pub unsafe fn to_mut_ptr < T > ( v : & [ mut T ] ) -> * mut T {
2070
2070
let repr: * * SliceRepr = :: cast:: transmute ( & v) ;
2071
2071
return :: cast:: reinterpret_cast ( & addr_of ( & ( ( * * repr) . data ) ) ) ;
2072
2072
}
@@ -2099,7 +2099,7 @@ pub mod raw {
2099
2099
* is newly allocated.
2100
2100
*/
2101
2101
#[ inline( always) ]
2102
- pub unsafe fn init_elem < T > ( v : & mut [ T ] , i : uint , val : T ) {
2102
+ pub unsafe fn init_elem < T > ( v : & [ mut T ] , i : uint , val : T ) {
2103
2103
let mut box = Some ( val) ;
2104
2104
do as_mut_buf( v) |p, _len| {
2105
2105
let mut box2 = None ;
@@ -2133,7 +2133,7 @@ pub mod raw {
2133
2133
* may overlap.
2134
2134
*/
2135
2135
#[ inline( always) ]
2136
- pub unsafe fn copy_memory < T > ( dst : & mut [ T ] , src : & [ const T ] ,
2136
+ pub unsafe fn copy_memory < T > ( dst : & [ mut T ] , src : & [ const T ] ,
2137
2137
count : uint ) {
2138
2138
assert dst. len ( ) >= count;
2139
2139
assert src. len ( ) >= count;
@@ -2200,7 +2200,7 @@ pub mod bytes {
2200
2200
* may overlap.
2201
2201
*/
2202
2202
#[ inline( always) ]
2203
- pub fn copy_memory ( dst : & mut [ u8 ] , src : & [ const u8 ] , count : uint ) {
2203
+ pub fn copy_memory ( dst : & [ mut u8] , src : & [ const u8 ] , count : uint ) {
2204
2204
// Bound checks are done at vec::raw::copy_memory.
2205
2205
unsafe { vec:: raw:: copy_memory ( dst, src, count) }
2206
2206
}
@@ -3155,7 +3155,7 @@ mod tests {
3155
3155
3156
3156
#[ test]
3157
3157
fn reverse_and_reversed ( ) {
3158
- let mut v: ~[ int ] = ~[ 10 , 20 ] ;
3158
+ let v: ~[ mut int] = ~[ mut 10 , 20 ] ;
3159
3159
assert ( v[ 0 ] == 10 ) ;
3160
3160
assert ( v[ 1 ] == 20 ) ;
3161
3161
reverse ( v) ;
@@ -3170,13 +3170,13 @@ mod tests {
3170
3170
3171
3171
let v4 = reversed :: < int > ( ~[ ] ) ;
3172
3172
assert ( v4 == ~[ ] ) ;
3173
- let mut v3: ~[ int ] = ~[ ] ;
3173
+ let v3: ~[ mut int] = ~[ mut ] ;
3174
3174
reverse :: < int > ( v3) ;
3175
3175
}
3176
3176
3177
3177
#[ test]
3178
3178
fn reversed_mut ( ) {
3179
- let mut v2 = reversed :: < int > ( ~[ 10 , 20 ] ) ;
3179
+ let v2 = reversed :: < int > ( ~[ mut 10 , 20 ] ) ;
3180
3180
assert ( v2[ 0 ] == 20 ) ;
3181
3181
assert ( v2[ 1 ] == 10 ) ;
3182
3182
}
@@ -3302,7 +3302,7 @@ mod tests {
3302
3302
#[ test]
3303
3303
fn cast_from_mut_no_copy ( ) {
3304
3304
unsafe {
3305
- let mut x = ~[ 1 , 2 , 3 ] ;
3305
+ let x = ~[ mut 1 , 2 , 3 ] ;
3306
3306
let addr = raw:: to_ptr ( x) ;
3307
3307
let x_imm = cast_from_mut ( x) ;
3308
3308
let addr_imm = raw:: to_ptr ( x_imm) ;
@@ -3564,7 +3564,7 @@ mod tests {
3564
3564
#[ ignore( windows) ]
3565
3565
#[ should_fail]
3566
3566
fn test_consume_mut_fail ( ) {
3567
- let mut v = ~[ ( ~0 , @0 ) , ( ~0 , @0 ) , ( ~0 , @0 ) , ( ~0 , @0 ) ] ;
3567
+ let v = ~[ mut ( ~0 , @0 ) , ( ~0 , @0 ) , ( ~0 , @0 ) , ( ~0 , @0 ) ] ;
3568
3568
let mut i = 0 ;
3569
3569
do consume_mut ( v) |_i, _elt| {
3570
3570
if i == 2 {
@@ -3592,7 +3592,7 @@ mod tests {
3592
3592
#[ ignore( windows) ]
3593
3593
#[ should_fail]
3594
3594
fn test_map_fail ( ) {
3595
- let mut v = [ ( ~0 , @0 ) , ( ~0 , @0 ) , ( ~0 , @0 ) , ( ~0 , @0 ) ] ;
3595
+ let v = [ mut ( ~0 , @0 ) , ( ~0 , @0 ) , ( ~0 , @0 ) , ( ~0 , @0 ) ] ;
3596
3596
let mut i = 0 ;
3597
3597
do map( v) |_elt| {
3598
3598
if i == 2 {
@@ -3918,7 +3918,7 @@ mod tests {
3918
3918
#[ ignore( cfg( windows) ) ]
3919
3919
#[ should_fail]
3920
3920
fn test_as_mut_buf_fail ( ) {
3921
- let mut v = [ ( ~0 , @0 ) , ( ~0 , @0 ) , ( ~0 , @0 ) , ( ~0 , @0 ) ] ;
3921
+ let v = [ mut ( ~0 , @0 ) , ( ~0 , @0 ) , ( ~0 , @0 ) , ( ~0 , @0 ) ] ;
3922
3922
do as_mut_buf( v) |_buf, _i| {
3923
3923
fail
3924
3924
}
@@ -3929,7 +3929,7 @@ mod tests {
3929
3929
#[ ignore( cfg( windows) ) ]
3930
3930
fn test_copy_memory_oob ( ) {
3931
3931
unsafe {
3932
- let mut a = [ 1 , 2 , 3 , 4 ] ;
3932
+ let a = [ mut 1 , 2 , 3 , 4 ] ;
3933
3933
let b = [ 1 , 2 , 3 , 4 , 5 ] ;
3934
3934
raw:: copy_memory ( a, b, 5 ) ;
3935
3935
}
0 commit comments