From 83d601d38cb11edee01fd6cbd3b7635db5bed337 Mon Sep 17 00:00:00 2001 From: Ammar Askar Date: Sat, 31 Oct 2020 15:55:07 -0700 Subject: [PATCH] Add a Sync bound for GenericMutexGuard. Fixes #53. --- src/sync/mutex.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sync/mutex.rs b/src/sync/mutex.rs index c301548..a26f472 100644 --- a/src/sync/mutex.rs +++ b/src/sync/mutex.rs @@ -310,6 +310,13 @@ impl DerefMut for GenericMutexGuard<'_, MutexType, T> { } } +// Safety: GenericMutexGuard may only be used across threads if the underlying +// type is Sync. +unsafe impl Sync + for GenericMutexGuard<'_, MutexType, T> +{ +} + /// A future which resolves when the target mutex has been successfully acquired. #[must_use = "futures do nothing unless polled"] pub struct GenericMutexLockFuture<'a, MutexType: RawMutex, T: 'a> {