Move Unpin impl near Drop impl
These traits are closely related. The meaning of Pin<P> when P isn't
Unpin is that in between when P ends up in the pin and when P's Drop
impl begins running, it must not be moved. Moving before the pin, or
moving from within drop once the Drop impl is in progress, are fine.
diff --git a/src/unique_ptr.rs b/src/unique_ptr.rs
index 3e07e2e..3399205 100644
--- a/src/unique_ptr.rs
+++ b/src/unique_ptr.rs
@@ -112,6 +112,10 @@
unsafe impl<T> Send for UniquePtr<T> where T: Send + UniquePtrTarget {}
unsafe impl<T> Sync for UniquePtr<T> where T: Sync + UniquePtrTarget {}
+// UniquePtr is not a self-referential type and is safe to move out of a Pin,
+// regardless whether the pointer's target is Unpin.
+impl<T> Unpin for UniquePtr<T> where T: UniquePtrTarget {}
+
impl<T> Drop for UniquePtr<T>
where
T: UniquePtrTarget,
@@ -177,10 +181,6 @@
}
}
-// UniquePtr is not a self-referential type and is safe to move out of a Pin,
-// regardless whether the pointer's target is Unpin.
-impl<T> Unpin for UniquePtr<T> where T: UniquePtrTarget {}
-
/// Trait bound for types which may be used as the `T` inside of a
/// `UniquePtr<T>` in generic code.
///