From a4ac2280f46599655b12a6abd0252c85d69e09c9 Mon Sep 17 00:00:00 2001 From: rusty Date: Tue, 8 Jun 2021 03:46:40 +0900 Subject: [PATCH] Derive Default trait for mutexes --- src/mutex.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mutex.rs b/src/mutex.rs index 47f3cbe..a5f266f 100644 --- a/src/mutex.rs +++ b/src/mutex.rs @@ -6,6 +6,7 @@ pub extern crate mutex_trait; pub use mutex_trait::Mutex; /// A spinlock and critical section section based mutex. +#[derive(Default)] pub struct CriticalSectionSpinLockMutex { data: spin::Mutex, } @@ -39,6 +40,7 @@ unsafe impl Sync for CriticalSectionSpinLockMutex where T: Send {} /// **This Mutex is only safe on single-core applications.** /// /// A `CriticalSection` **is not sufficient** to ensure exclusive access across cores. +#[derive(Default)] pub struct CriticalSectionMutex { data: UnsafeCell, } @@ -66,6 +68,7 @@ impl mutex_trait::Mutex for &'_ CriticalSectionMutex { unsafe impl Sync for CriticalSectionMutex where T: Send {} /// A spinlock based mutex. +#[derive(Default)] pub struct SpinLockMutex { data: spin::Mutex, }