@@ -86,11 +86,11 @@ pub unsafe fn position<T>(buf: *T, f: &fn(&T) -> bool) -> uint {
86
86
87
87
/// Create an unsafe null pointer
88
88
#[ inline( always) ]
89
- pub fn null < T > ( ) -> * T { unsafe { cast:: reinterpret_cast ( & 0 u) } }
89
+ pub fn null < T > ( ) -> * T { unsafe { cast:: transmute ( 0 u) } }
90
90
91
91
/// Create an unsafe mutable null pointer
92
92
#[ inline( always) ]
93
- pub fn mut_null < T > ( ) -> * mut T { unsafe { cast:: reinterpret_cast ( & 0 u) } }
93
+ pub fn mut_null < T > ( ) -> * mut T { unsafe { cast:: transmute ( 0 u) } }
94
94
95
95
/// Returns true if the pointer is equal to the null pointer.
96
96
#[ inline( always) ]
@@ -134,7 +134,7 @@ pub unsafe fn set_memory<T>(dst: *mut T, c: int, count: uint) {
134
134
*/
135
135
#[ inline( always) ]
136
136
pub fn to_unsafe_ptr < T > ( thing : & T ) -> * T {
137
- unsafe { cast:: reinterpret_cast ( & thing) }
137
+ unsafe { cast:: transmute ( thing) }
138
138
}
139
139
140
140
/**
@@ -144,7 +144,7 @@ pub fn to_unsafe_ptr<T>(thing: &T) -> *T {
144
144
*/
145
145
#[ inline( always) ]
146
146
pub fn to_const_unsafe_ptr < T > ( thing : & const T ) -> * const T {
147
- unsafe { cast:: reinterpret_cast ( & thing) }
147
+ unsafe { cast:: transmute ( thing) }
148
148
}
149
149
150
150
/**
@@ -154,7 +154,7 @@ pub fn to_const_unsafe_ptr<T>(thing: &const T) -> *const T {
154
154
*/
155
155
#[ inline( always) ]
156
156
pub fn to_mut_unsafe_ptr < T > ( thing : & mut T ) -> * mut T {
157
- unsafe { cast:: reinterpret_cast ( & thing) }
157
+ unsafe { cast:: transmute ( thing) }
158
158
}
159
159
160
160
/**
@@ -167,7 +167,7 @@ pub fn to_mut_unsafe_ptr<T>(thing: &mut T) -> *mut T {
167
167
#[ inline( always) ]
168
168
pub fn to_uint < T > ( thing : & T ) -> uint {
169
169
unsafe {
170
- cast:: reinterpret_cast ( & thing)
170
+ cast:: transmute ( thing)
171
171
}
172
172
}
173
173
@@ -259,8 +259,8 @@ impl<T> Eq for *const T {
259
259
#[inline(always)]
260
260
fn eq(&self, other: &*const T) -> bool {
261
261
unsafe {
262
- let a: uint = cast::reinterpret_cast(&( *self) );
263
- let b: uint = cast::reinterpret_cast(&( *other) );
262
+ let a: uint = cast::transmute( *self);
263
+ let b: uint = cast::transmute( *other);
264
264
return a == b;
265
265
}
266
266
}
@@ -274,32 +274,32 @@ impl<T> Ord for *const T {
274
274
#[inline(always)]
275
275
fn lt(&self, other: &*const T) -> bool {
276
276
unsafe {
277
- let a: uint = cast::reinterpret_cast(&( *self) );
278
- let b: uint = cast::reinterpret_cast(&( *other) );
277
+ let a: uint = cast::transmute( *self);
278
+ let b: uint = cast::transmute( *other);
279
279
return a < b;
280
280
}
281
281
}
282
282
#[inline(always)]
283
283
fn le(&self, other: &*const T) -> bool {
284
284
unsafe {
285
- let a: uint = cast::reinterpret_cast(&( *self) );
286
- let b: uint = cast::reinterpret_cast(&( *other) );
285
+ let a: uint = cast::transmute( *self);
286
+ let b: uint = cast::transmute( *other);
287
287
return a <= b;
288
288
}
289
289
}
290
290
#[inline(always)]
291
291
fn ge(&self, other: &*const T) -> bool {
292
292
unsafe {
293
- let a: uint = cast::reinterpret_cast(&( *self) );
294
- let b: uint = cast::reinterpret_cast(&( *other) );
293
+ let a: uint = cast::transmute( *self);
294
+ let b: uint = cast::transmute( *other);
295
295
return a >= b;
296
296
}
297
297
}
298
298
#[inline(always)]
299
299
fn gt(&self, other: &*const T) -> bool {
300
300
unsafe {
301
- let a: uint = cast::reinterpret_cast(&( *self) );
302
- let b: uint = cast::reinterpret_cast(&( *other) );
301
+ let a: uint = cast::transmute( *self);
302
+ let b: uint = cast::transmute( *other);
303
303
return a > b;
304
304
}
305
305
}
@@ -350,7 +350,7 @@ pub mod ptr_tests {
350
350
struct Pair {mut fst: int, mut snd: int};
351
351
let mut p = Pair {fst: 10, snd: 20};
352
352
let pptr: *mut Pair = &mut p;
353
- let iptr: *mut int = cast::reinterpret_cast(& pptr);
353
+ let iptr: *mut int = cast::transmute( pptr);
354
354
assert!((*iptr == 10));;
355
355
*iptr = 30;
356
356
assert!((*iptr == 30));
0 commit comments