@@ -103,9 +103,9 @@ use slice::{Items, MutItems};
103
103
#[ unsafe_no_drop_flag]
104
104
#[ stable]
105
105
pub struct Vec < T > {
106
+ ptr : * mut T ,
106
107
len : uint ,
107
108
cap : uint ,
108
- ptr : * mut T
109
109
}
110
110
111
111
impl < T > Vec < T > {
@@ -125,7 +125,7 @@ impl<T> Vec<T> {
125
125
// non-null value which is fine since we never call deallocate on the ptr
126
126
// if cap is 0. The reason for this is because the pointer of a slice
127
127
// being NULL would break the null pointer optimization for enums.
128
- Vec { len : 0 , cap : 0 , ptr : EMPTY as * mut T }
128
+ Vec { ptr : EMPTY as * mut T , len : 0 , cap : 0 }
129
129
}
130
130
131
131
/// Constructs a new, empty `Vec` with the specified capacity.
@@ -159,14 +159,14 @@ impl<T> Vec<T> {
159
159
#[ stable]
160
160
pub fn with_capacity ( capacity : uint ) -> Vec < T > {
161
161
if mem:: size_of :: < T > ( ) == 0 {
162
- Vec { len : 0 , cap : uint:: MAX , ptr : EMPTY as * mut T }
162
+ Vec { ptr : EMPTY as * mut T , len : 0 , cap : uint:: MAX }
163
163
} else if capacity == 0 {
164
164
Vec :: new ( )
165
165
} else {
166
166
let size = capacity. checked_mul ( & mem:: size_of :: < T > ( ) )
167
167
. expect ( "capacity overflow" ) ;
168
168
let ptr = unsafe { allocate ( size, mem:: min_align_of :: < T > ( ) ) } ;
169
- Vec { len : 0 , cap : capacity , ptr : ptr as * mut T }
169
+ Vec { ptr : ptr as * mut T , len : 0 , cap : capacity }
170
170
}
171
171
}
172
172
@@ -237,9 +237,9 @@ impl<T> Vec<T> {
237
237
/// }
238
238
/// ```
239
239
#[ experimental]
240
- pub unsafe fn from_raw_parts ( length : uint , capacity : uint ,
241
- ptr : * mut T ) -> Vec < T > {
242
- Vec { len : length , cap : capacity , ptr : ptr }
240
+ pub unsafe fn from_raw_parts ( ptr : * mut T , length : uint ,
241
+ capacity : uint ) -> Vec < T > {
242
+ Vec { ptr : ptr , len : length , cap : capacity }
243
243
}
244
244
245
245
/// Consumes the `Vec`, partitioning it based on a predicate.
@@ -1680,7 +1680,7 @@ impl<'a, T> Drop for DerefVec<'a, T> {
1680
1680
pub fn as_vec < ' a , T > ( x : & ' a [ T ] ) -> DerefVec < ' a , T > {
1681
1681
unsafe {
1682
1682
DerefVec {
1683
- x : Vec :: from_raw_parts ( x. len ( ) , x. len ( ) , x. as_ptr ( ) as * mut T ) ,
1683
+ x : Vec :: from_raw_parts ( x. as_ptr ( ) as * mut T , x. len ( ) , x. len ( ) ) ,
1684
1684
l : ContravariantLifetime :: < ' a >
1685
1685
}
1686
1686
}
@@ -1929,7 +1929,7 @@ impl<T> Vec<T> {
1929
1929
let vec_cap = pv. vec . capacity ( ) ;
1930
1930
let vec_ptr = pv. vec . as_mut_ptr ( ) as * mut U ;
1931
1931
mem:: forget ( pv) ;
1932
- Vec :: from_raw_parts ( vec_len , vec_cap , vec_ptr )
1932
+ Vec :: from_raw_parts ( vec_ptr , vec_len , vec_cap )
1933
1933
}
1934
1934
} else {
1935
1935
// Put the `Vec` into the `PartialVecZeroSized` structure and
0 commit comments