]> git.lizzy.rs Git - rust.git/blobdiff - src/libcore/ptr.rs
Merge pull request #20674 from jbcrail/fix-misspelled-comments
[rust.git] / src / libcore / ptr.rs
index faf1d781465c76457b4d08ef731a0cd58fcec2c3..20305c3191a098f24f73e1503f7e3a68595b4208 100644 (file)
 use mem;
 use clone::Clone;
 use intrinsics;
-use option::Option::{mod, Some, None};
-use kinds::{Send, Sync};
+use option::Option::{self, Some, None};
+use marker::{Send, Sized, Sync};
 
-use cmp::{PartialEq, Eq, Ord, PartialOrd, Equiv};
-use cmp::Ordering::{mod, Less, Equal, Greater};
+use cmp::{PartialEq, Eq, Ord, PartialOrd};
+use cmp::Ordering::{self, Less, Equal, Greater};
 
-// FIXME #19649: instrinsic docs don't render, so these have no docs :(
+// FIXME #19649: intrinsic docs don't render, so these have no docs :(
 
 #[unstable]
 pub use intrinsics::copy_nonoverlapping_memory;
@@ -233,7 +233,7 @@ pub unsafe fn read_and_zero<T>(dest: *mut T) -> T {
 /// not drop the contents of `dst`. This could leak allocations or resources,
 /// so care must be taken not to overwrite an object that should be dropped.
 ///
-/// This is appropriate for initializing uninitialized memory, or overwritting
+/// This is appropriate for initializing uninitialized memory, or overwriting
 /// memory that has previously been `read` from.
 #[inline]
 #[stable]
@@ -243,23 +243,13 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
 
 /// Methods on raw pointers
 #[stable]
-pub trait PtrExt<T> {
-    /// Returns the null pointer.
-    #[deprecated = "call ptr::null instead"]
-    fn null() -> Self;
+pub trait PtrExt: Sized {
+    type Target;
 
     /// Returns true if the pointer is null.
     #[stable]
     fn is_null(self) -> bool;
 
-    /// Returns true if the pointer is not equal to the null pointer.
-    #[deprecated = "use !p.is_null() instead"]
-    fn is_not_null(self) -> bool { !self.is_null() }
-
-    /// Returns true if the pointer is not null.
-    #[deprecated = "use `as uint` instead"]
-    fn to_uint(self) -> uint;
-
     /// Returns `None` if the pointer is null, or else returns a reference to
     /// the value wrapped in `Some`.
     ///
@@ -271,7 +261,7 @@ fn is_not_null(self) -> bool { !self.is_null() }
     /// memory.
     #[unstable = "Option is not clearly the right return type, and we may want \
                   to tie the return lifetime to a borrow of the raw pointer"]
-    unsafe fn as_ref<'a>(&self) -> Option<&'a T>;
+    unsafe fn as_ref<'a>(&self) -> Option<&'a Self::Target>;
 
     /// Calculates the offset from a pointer. `count` is in units of T; e.g. a
     /// `count` of 3 represents a pointer offset of `3 * sizeof::<T>()` bytes.
@@ -287,7 +277,9 @@ fn is_not_null(self) -> bool { !self.is_null() }
 
 /// Methods on mutable raw pointers
 #[stable]
-pub trait MutPtrExt<T>{
+pub trait MutPtrExt {
+    type Target;
+
     /// Returns `None` if the pointer is null, or else returns a mutable
     /// reference to the value wrapped in `Some`.
     ///
@@ -297,23 +289,17 @@ pub trait MutPtrExt<T>{
     /// of the returned pointer.
     #[unstable = "Option is not clearly the right return type, and we may want \
                   to tie the return lifetime to a borrow of the raw pointer"]
-    unsafe fn as_mut<'a>(&self) -> Option<&'a mut T>;
+    unsafe fn as_mut<'a>(&self) -> Option<&'a mut Self::Target>;
 }
 
 #[stable]
-impl<T> PtrExt<T> for *const T {
-    #[inline]
-    #[deprecated = "call ptr::null instead"]
-    fn null() -> *const T { null() }
+impl<T> PtrExt for *const T {
+    type Target = T;
 
     #[inline]
     #[stable]
     fn is_null(self) -> bool { self as uint == 0 }
 
-    #[inline]
-    #[deprecated = "use `as uint` instead"]
-    fn to_uint(self) -> uint { self as uint }
-
     #[inline]
     #[stable]
     unsafe fn offset(self, count: int) -> *const T {
@@ -333,19 +319,13 @@ unsafe fn as_ref<'a>(&self) -> Option<&'a T> {
 }
 
 #[stable]
-impl<T> PtrExt<T> for *mut T {
-    #[inline]
-    #[deprecated = "call ptr::null instead"]
-    fn null() -> *mut T { null_mut() }
+impl<T> PtrExt for *mut T {
+    type Target = T;
 
     #[inline]
     #[stable]
     fn is_null(self) -> bool { self as uint == 0 }
 
-    #[inline]
-    #[deprecated = "use `as uint` instead"]
-    fn to_uint(self) -> uint { self as uint }
-
     #[inline]
     #[stable]
     unsafe fn offset(self, count: int) -> *mut T {
@@ -365,7 +345,9 @@ unsafe fn as_ref<'a>(&self) -> Option<&'a T> {
 }
 
 #[stable]
-impl<T> MutPtrExt<T> for *mut T {
+impl<T> MutPtrExt for *mut T {
+    type Target = T;
+
     #[inline]
     #[unstable = "return value does not necessarily convey all possible \
                   information"]
@@ -405,23 +387,6 @@ fn ne(&self, other: &*mut T) -> bool { !self.eq(other) }
 #[stable]
 impl<T> Eq for *mut T {}
 
-// Equivalence for pointers
-#[allow(deprecated)]
-#[deprecated = "Use overloaded `core::cmp::PartialEq`"]
-impl<T> Equiv<*mut T> for *const T {
-    fn equiv(&self, other: &*mut T) -> bool {
-        self.to_uint() == other.to_uint()
-    }
-}
-
-#[allow(deprecated)]
-#[deprecated = "Use overloaded `core::cmp::PartialEq`"]
-impl<T> Equiv<*const T> for *mut T {
-    fn equiv(&self, other: &*const T) -> bool {
-        self.to_uint() == other.to_uint()
-    }
-}
-
 #[stable]
 impl<T> Clone for *const T {
     #[inline]