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;
/// 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]
/// 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`.
///
/// 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.
/// 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`.
///
/// 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 {
}
#[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 {
}
#[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"]
}
// Equality for pointers
+#[stable]
impl<T> PartialEq for *const T {
#[inline]
fn eq(&self, other: &*const T) -> bool {
fn ne(&self, other: &*const T) -> bool { !self.eq(other) }
}
+#[stable]
impl<T> Eq for *const T {}
+#[stable]
impl<T> PartialEq for *mut T {
#[inline]
fn eq(&self, other: &*mut T) -> bool {
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]
use mem;
use cmp::PartialEq;
+ #[stable]
impl<_R> PartialEq for extern "C" fn() -> _R {
#[inline]
fn eq(&self, other: &extern "C" fn() -> _R) -> bool {
}
macro_rules! fnptreq {
($($p:ident),*) => {
+ #[stable]
impl<_R,$($p),*> PartialEq for extern "C" fn($($p),*) -> _R {
#[inline]
fn eq(&self, other: &extern "C" fn($($p),*) -> _R) -> bool {
}
// Comparison for pointers
+#[stable]
impl<T> Ord for *const T {
#[inline]
fn cmp(&self, other: &*const T) -> Ordering {
}
}
+#[stable]
impl<T> PartialOrd for *const T {
#[inline]
fn partial_cmp(&self, other: &*const T) -> Option<Ordering> {
fn ge(&self, other: &*const T) -> bool { *self >= *other }
}
+#[stable]
impl<T> Ord for *mut T {
#[inline]
fn cmp(&self, other: &*mut T) -> Ordering {
}
}
+#[stable]
impl<T> PartialOrd for *mut T {
#[inline]
fn partial_cmp(&self, other: &*mut T) -> Option<Ordering> {