Skip to content

Commit c15df8e

Browse files
committed
libcore: Don't impl RawPtr* traits for NonZero.
1 parent b44d7cb commit c15df8e

File tree

2 files changed

+2
-63
lines changed

2 files changed

+2
-63
lines changed

src/libcollections/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ impl<T> Vec<T> {
11201120
}
11211121

11221122
unsafe {
1123-
let end = *self.ptr.offset(self.len as int);
1123+
let end = (*self.ptr).offset(self.len as int);
11241124
ptr::write(&mut *end, value);
11251125
self.len += 1;
11261126
}

src/libcore/nonzero.rs

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@
1010

1111
//! Exposes the NonZero lang item which provides optimization hints.
1212
13-
use cmp::Eq;
14-
use intrinsics;
15-
use kinds::Copy;
1613
use ops::Deref;
17-
use option::Option;
18-
use option::Option::Some;
19-
use ptr::{null, null_mut, RawPtr, RawMutPtr};
2014

2115
/// A wrapper type for raw pointers and integers that will never be
2216
/// NULL or 0 that might allow certain optimizations.
2317
#[lang="non_zero"]
24-
#[deriving(Clone, PartialEq, Eq, PartialOrd)]
18+
#[deriving(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Show)]
2519
#[experimental]
2620
pub struct NonZero<T>(T);
2721

@@ -34,65 +28,10 @@ impl<T> NonZero<T> {
3428
}
3529
}
3630

37-
impl<T: Copy> Copy for NonZero<T> {}
38-
3931
impl<T> Deref<T> for NonZero<T> {
4032
#[inline]
4133
fn deref<'a>(&'a self) -> &'a T {
4234
let NonZero(ref inner) = *self;
4335
inner
4436
}
4537
}
46-
47-
impl<T> RawPtr<T> for NonZero<*const T> {
48-
#[inline]
49-
fn null() -> NonZero<*const T> { NonZero(null()) }
50-
51-
#[inline]
52-
fn is_null(&self) -> bool { false }
53-
54-
#[inline]
55-
fn to_uint(&self) -> uint {
56-
**self as uint
57-
}
58-
59-
#[inline]
60-
unsafe fn offset(self, count: int) -> NonZero<*const T> {
61-
NonZero(intrinsics::offset(*self, count))
62-
}
63-
64-
#[inline]
65-
unsafe fn as_ref<'a>(&self) -> Option<&'a T> {
66-
Some(&***self)
67-
}
68-
}
69-
70-
impl<T> RawPtr<T> for NonZero<*mut T> {
71-
#[inline]
72-
fn null() -> NonZero<*mut T> { NonZero(null_mut()) }
73-
74-
#[inline]
75-
fn is_null(&self) -> bool { false }
76-
77-
#[inline]
78-
fn to_uint(&self) -> uint {
79-
**self as uint
80-
}
81-
82-
#[inline]
83-
unsafe fn offset(self, count: int) -> NonZero<*mut T> {
84-
NonZero(intrinsics::offset(*self as *const T, count) as *mut T)
85-
}
86-
87-
#[inline]
88-
unsafe fn as_ref<'a>(&self) -> Option<&'a T> {
89-
Some(&***self)
90-
}
91-
}
92-
93-
impl<T> RawMutPtr<T> for NonZero<*mut T> {
94-
#[inline]
95-
unsafe fn as_mut<'a>(&self) -> Option<&'a mut T> {
96-
Some(&mut ***self)
97-
}
98-
}

0 commit comments

Comments
 (0)