diff options
| author | Alexis Beingessner <a.beingessner@gmail.com> | 2017-04-04 12:31:03 -0400 |
|---|---|---|
| committer | Alexis Beingessner <a.beingessner@gmail.com> | 2017-05-04 14:56:02 -0400 |
| commit | 6e2efe3aa477bdc8d7ccdb904523ad18d612bbb6 (patch) | |
| tree | 3a4b401ff3856ccfd94fb6cf22f04be44bdcfa08 /src/libcore/nonzero.rs | |
| parent | ed1f26ddda15b2bcf613a257e813e8b02ee14dff (diff) | |
| download | rust-6e2efe3aa477bdc8d7ccdb904523ad18d612bbb6.tar.gz rust-6e2efe3aa477bdc8d7ccdb904523ad18d612bbb6.zip | |
refactor NonZero, Shared, and Unique APIs
Major difference is that I removed Deref impls, as apparently LLVM has trouble maintaining metadata with a `&ptr -> &ptr` API. This was cited as a blocker for ever stabilizing this API. It wasn't that ergonomic anyway. * Added `get` to NonZero to replace Deref impl * Added `as_ptr` to Shared/Unique to replace Deref impl * Added Unique's `as_ref` and `as_mut` conveniences to Shared * Added `::empty()` convenience constructor for Unique/Shared * Deprecated `as_mut_ptr` on Shared in favour of `as_ptr` * Improved documentation of types Note that Shared now only refers to *mut, and not *const
Diffstat (limited to 'src/libcore/nonzero.rs')
| -rw-r--r-- | src/libcore/nonzero.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/libcore/nonzero.rs b/src/libcore/nonzero.rs index d7382501bc3..d93085e96db 100644 --- a/src/libcore/nonzero.rs +++ b/src/libcore/nonzero.rs @@ -13,7 +13,7 @@ reason = "needs an RFC to flesh out the design", issue = "27730")] -use ops::{CoerceUnsized, Deref}; +use ops::CoerceUnsized; /// Unsafe trait to indicate what types are usable with the NonZero struct pub unsafe trait Zeroable {} @@ -46,15 +46,10 @@ impl<T: Zeroable> NonZero<T> { pub const unsafe fn new(inner: T) -> NonZero<T> { NonZero(inner) } -} - -impl<T: Zeroable> Deref for NonZero<T> { - type Target = T; - #[inline] - fn deref(&self) -> &T { - let NonZero(ref inner) = *self; - inner + /// Gets the inner value. + pub fn get(self) -> T { + self.0 } } |
