about summary refs log tree commit diff
path: root/src/libcore/ptr.rs
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-09-18 17:34:08 -0700
committerBrian Anderson <banderson@mozilla.com>2012-09-18 19:36:25 -0700
commit2906f2de31d3a4709a2e028c5cefe3274df1edd2 (patch)
tree608d302d2da9538bc12cdf286437a6cd654c7535 /src/libcore/ptr.rs
parent77480e8e44d9c5a6858172faeb291496314cf739 (diff)
downloadrust-2906f2de31d3a4709a2e028c5cefe3274df1edd2.tar.gz
rust-2906f2de31d3a4709a2e028c5cefe3274df1edd2.zip
core: Rename 'unsafe' mod to 'cast'
Diffstat (limited to 'src/libcore/ptr.rs')
-rw-r--r--src/libcore/ptr.rs36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index 58ccc89e88f..31c52f0b407 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -53,7 +53,7 @@ pure fn addr_of<T>(val: T) -> *T { unsafe { rusti::addr_of(val) } }
 #[inline(always)]
 pure fn mut_addr_of<T>(val: T) -> *mut T {
     unsafe {
-        unsafe::reinterpret_cast(&rusti::addr_of(val))
+        cast::reinterpret_cast(&rusti::addr_of(val))
     }
 }
 
@@ -97,11 +97,11 @@ unsafe fn position<T>(buf: *T, f: fn(T) -> bool) -> uint {
 
 /// Create an unsafe null pointer
 #[inline(always)]
-pure fn null<T>() -> *T { unsafe { unsafe::reinterpret_cast(&0u) } }
+pure fn null<T>() -> *T { unsafe { cast::reinterpret_cast(&0u) } }
 
 /// Create an unsafe mutable null pointer
 #[inline(always)]
-pure fn mut_null<T>() -> *mut T { unsafe { unsafe::reinterpret_cast(&0u) } }
+pure fn mut_null<T>() -> *mut T { unsafe { cast::reinterpret_cast(&0u) } }
 
 /// Returns true if the pointer is equal to the null pointer.
 pure fn is_null<T>(ptr: *const T) -> bool { ptr == null() }
@@ -147,7 +147,7 @@ unsafe fn memset<T>(dst: *mut T, c: int, count: uint)  {
 */
 #[inline(always)]
 fn to_unsafe_ptr<T>(thing: &T) -> *T {
-    unsafe { unsafe::reinterpret_cast(&thing) }
+    unsafe { cast::reinterpret_cast(&thing) }
 }
 
 /**
@@ -157,7 +157,7 @@ fn to_unsafe_ptr<T>(thing: &T) -> *T {
 */
 #[inline(always)]
 fn to_const_unsafe_ptr<T>(thing: &const T) -> *const T {
-    unsafe { unsafe::reinterpret_cast(&thing) }
+    unsafe { cast::reinterpret_cast(&thing) }
 }
 
 /**
@@ -167,7 +167,7 @@ fn to_const_unsafe_ptr<T>(thing: &const T) -> *const T {
 */
 #[inline(always)]
 fn to_mut_unsafe_ptr<T>(thing: &mut T) -> *mut T {
-    unsafe { unsafe::reinterpret_cast(&thing) }
+    unsafe { cast::reinterpret_cast(&thing) }
 }
 
 /**
@@ -179,7 +179,7 @@ fn to_mut_unsafe_ptr<T>(thing: &mut T) -> *mut T {
 */
 #[inline(always)]
 fn to_uint<T>(thing: &T) -> uint unsafe {
-    unsafe::reinterpret_cast(&thing)
+    cast::reinterpret_cast(&thing)
 }
 
 /// Determine if two borrowed pointers point to the same thing.
@@ -205,8 +205,8 @@ impl<T> *T: Ptr {
 // Equality for pointers
 impl<T> *const T : Eq {
     pure fn eq(&&other: *const T) -> bool unsafe {
-        let a: uint = unsafe::reinterpret_cast(&self);
-        let b: uint = unsafe::reinterpret_cast(&other);
+        let a: uint = cast::reinterpret_cast(&self);
+        let b: uint = cast::reinterpret_cast(&other);
         return a == b;
     }
     pure fn ne(&&other: *const T) -> bool { !self.eq(other) }
@@ -215,23 +215,23 @@ impl<T> *const T : Eq {
 // Comparison for pointers
 impl<T> *const T : Ord {
     pure fn lt(&&other: *const T) -> bool unsafe {
-        let a: uint = unsafe::reinterpret_cast(&self);
-        let b: uint = unsafe::reinterpret_cast(&other);
+        let a: uint = cast::reinterpret_cast(&self);
+        let b: uint = cast::reinterpret_cast(&other);
         return a < b;
     }
     pure fn le(&&other: *const T) -> bool unsafe {
-        let a: uint = unsafe::reinterpret_cast(&self);
-        let b: uint = unsafe::reinterpret_cast(&other);
+        let a: uint = cast::reinterpret_cast(&self);
+        let b: uint = cast::reinterpret_cast(&other);
         return a <= b;
     }
     pure fn ge(&&other: *const T) -> bool unsafe {
-        let a: uint = unsafe::reinterpret_cast(&self);
-        let b: uint = unsafe::reinterpret_cast(&other);
+        let a: uint = cast::reinterpret_cast(&self);
+        let b: uint = cast::reinterpret_cast(&other);
         return a >= b;
     }
     pure fn gt(&&other: *const T) -> bool unsafe {
-        let a: uint = unsafe::reinterpret_cast(&self);
-        let b: uint = unsafe::reinterpret_cast(&other);
+        let a: uint = cast::reinterpret_cast(&self);
+        let b: uint = cast::reinterpret_cast(&other);
         return a > b;
     }
 }
@@ -256,7 +256,7 @@ fn test() {
         type Pair = {mut fst: int, mut snd: int};
         let p = {mut fst: 10, mut snd: 20};
         let pptr: *mut Pair = mut_addr_of(p);
-        let iptr: *mut int = unsafe::reinterpret_cast(&pptr);
+        let iptr: *mut int = cast::reinterpret_cast(&pptr);
         assert (*iptr == 10);;
         *iptr = 30;
         assert (*iptr == 30);