9090use mem;
9191use clone:: Clone ;
9292use intrinsics;
93- use kinds:: { Copy , Send , Sync } ;
94- use ops:: Deref ;
93+ use kinds:: { Send , Sync } ;
9594use option:: Option ;
9695use option:: Option :: { Some , None } ;
9796
@@ -111,32 +110,6 @@ pub use intrinsics::copy_memory;
111110pub use intrinsics:: set_memory;
112111
113112
114- /// A wrapper type for raw pointers and integers that will never be
115- /// NULL or 0 that might allow certain optimizations.
116- #[ lang="non_zero" ]
117- #[ deriving( Clone , PartialEq , Eq , PartialOrd ) ]
118- #[ experimental]
119- pub struct NonZero < T > ( T ) ;
120-
121- impl < T > NonZero < T > {
122- /// Create an instance of NonZero with the provided value.
123- /// You must indeed ensure that the value is actually "non-zero".
124- #[ inline( always) ]
125- pub unsafe fn new ( inner : T ) -> NonZero < T > {
126- NonZero ( inner)
127- }
128- }
129-
130- impl < T > Deref < T > for NonZero < T > {
131- #[ inline]
132- fn deref < ' a > ( & ' a self ) -> & ' a T {
133- let NonZero ( ref inner) = * self ;
134- inner
135- }
136- }
137-
138- impl < T : Copy > Copy for NonZero < T > { }
139-
140113/// Creates a null raw pointer.
141114///
142115/// # Examples
@@ -341,32 +314,6 @@ impl<T> RawPtr<T> for *const T {
341314 }
342315}
343316
344- impl < T > RawPtr < T > for NonZero < * const T > {
345- #[ inline]
346- fn null ( ) -> NonZero < * const T > { NonZero ( null ( ) ) }
347-
348- #[ inline]
349- fn is_null ( & self ) -> bool { false }
350-
351- #[ inline]
352- fn to_uint ( & self ) -> uint {
353- let NonZero ( p) = * self ;
354- p as uint
355- }
356-
357- #[ inline]
358- unsafe fn offset ( self , count : int ) -> NonZero < * const T > {
359- let NonZero ( p) = self ;
360- NonZero ( intrinsics:: offset ( p, count) )
361- }
362-
363- #[ inline]
364- unsafe fn as_ref < ' a > ( & self ) -> Option < & ' a T > {
365- let NonZero ( p) = * self ;
366- Some ( & * p)
367- }
368- }
369-
370317impl < T > RawPtr < T > for * mut T {
371318 #[ inline]
372319 fn null ( ) -> * mut T { null_mut ( ) }
@@ -392,32 +339,6 @@ impl<T> RawPtr<T> for *mut T {
392339 }
393340}
394341
395- impl < T > RawPtr < T > for NonZero < * mut T > {
396- #[ inline]
397- fn null ( ) -> NonZero < * mut T > { NonZero ( null_mut ( ) ) }
398-
399- #[ inline]
400- fn is_null ( & self ) -> bool { false }
401-
402- #[ inline]
403- fn to_uint ( & self ) -> uint {
404- let NonZero ( p) = * self ;
405- p as uint
406- }
407-
408- #[ inline]
409- unsafe fn offset ( self , count : int ) -> NonZero < * mut T > {
410- let NonZero ( p) = self ;
411- NonZero ( intrinsics:: offset ( p as * const T , count) as * mut T )
412- }
413-
414- #[ inline]
415- unsafe fn as_ref < ' a > ( & self ) -> Option < & ' a T > {
416- let NonZero ( p) = * self ;
417- Some ( & * p)
418- }
419- }
420-
421342impl < T > RawMutPtr < T > for * mut T {
422343 #[ inline]
423344 unsafe fn as_mut < ' a > ( & self ) -> Option < & ' a mut T > {
@@ -429,14 +350,6 @@ impl<T> RawMutPtr<T> for *mut T {
429350 }
430351}
431352
432- impl < T > RawMutPtr < T > for NonZero < * mut T > {
433- #[ inline]
434- unsafe fn as_mut < ' a > ( & self ) -> Option < & ' a mut T > {
435- let NonZero ( p) = * self ;
436- Some ( & mut * p)
437- }
438- }
439-
440353// Equality for pointers
441354impl < T > PartialEq for * const T {
442355 #[ inline]
0 commit comments