]> git.lizzy.rs Git - rust.git/blobdiff - src/libcore/ptr.rs
Replace Unique<T> with NonZero<T> in Alloc trait
[rust.git] / src / libcore / ptr.rs
index fd8f9138f36513a3fad0aeb8a7b808f13c6ff1c9..89ecb3457fcb69baf43ccc94fbbaa1b50196df15 100644 (file)
@@ -2452,6 +2452,13 @@ fn from(reference: &'a T) -> Self {
     }
 }
 
+#[unstable(feature = "unique", issue = "27730")]
+impl<'a, T: ?Sized> From<NonNull<T>> for Unique<T> {
+    fn from(p: NonNull<T>) -> Self {
+        Unique { pointer: p.pointer, _marker: PhantomData }
+    }
+}
+
 /// Previous name of `NonNull`.
 #[rustc_deprecated(since = "1.24", reason = "renamed to `NonNull`")]
 #[unstable(feature = "shared", issue = "27730")]