From 640f6f07494ece4ebe7e4d9680fff9a83ab4b0d2 Mon Sep 17 00:00:00 2001 From: Taylor Cramer Date: Tue, 22 May 2018 17:10:14 -0700 Subject: [PATCH] Add Pinned type for opting out of Unpin on stable --- src/libcore/marker.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index d4a87b13f04d..77db165bcbde 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -607,6 +607,16 @@ unsafe impl<'a, T: ?Sized> Freeze for &'a mut T {} #[unstable(feature = "pin", issue = "49150")] pub auto trait Unpin {} +/// A type which does not implement `Unpin`. +/// +/// If a type contains a `Pinned`, it will not implement `Unpin` by default. +#[unstable(feature = "pin", issue = "49150")] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] +pub struct Pinned; + +#[unstable(feature = "pin", issue = "49150")] +impl !Unpin for Pinned {} + /// Implementations of `Copy` for primitive types. /// /// Implementations that cannot be described in Rust