Add an implementation of Zeroable for Unique<T>

This allows the use of `NonZero<Unique<T>>` for owned,
non-null raw pointers.

cc https://github.com/Gankro/collect-rs/pull/103
This commit is contained in:
Jonathan Reem 2015-01-27 18:17:04 -05:00
parent 777435990e
commit 83f8088108

View File

@ -11,12 +11,14 @@
//! Exposes the NonZero lang item which provides optimization hints.
use ops::Deref;
use ptr::Unique;
/// Unsafe trait to indicate what types are usable with the NonZero struct
pub unsafe trait Zeroable {}
unsafe impl<T> Zeroable for *const T {}
unsafe impl<T> Zeroable for *mut T {}
unsafe impl<T> Zeroable for Unique<T> { }
unsafe impl Zeroable for int {}
unsafe impl Zeroable for uint {}
unsafe impl Zeroable for i8 {}