diff --git a/src/sync/condvar.rs b/src/sync/condvar.rs index 93b1726cd..ba0a1770e 100644 --- a/src/sync/condvar.rs +++ b/src/sync/condvar.rs @@ -15,7 +15,7 @@ pub struct WaitTimeoutResult(bool); /// not impl WaitTimeoutResult { /// Returns `true` if the wait was known to have timed out. - pub fn timed_out(&self) -> bool { + pub fn timed_out(self) -> bool { self.0 } } @@ -62,6 +62,12 @@ pub struct Condvar { blocked: std::sync::Mutex>>, } +impl Default for Condvar { + fn default() -> Self { + Condvar::new() + } +} + impl Condvar { /// Creates a new condition variable /// @@ -111,6 +117,7 @@ impl Condvar { /// } /// # }) } /// ``` + #[allow(clippy::needless_lifetimes)] pub async fn wait<'a, T>(&self, guard: MutexGuard<'a, T>) -> MutexGuard<'a, T> { let mutex = guard_lock(&guard); @@ -161,6 +168,7 @@ impl Condvar { /// # }) } /// ``` #[cfg(feature = "unstable")] + #[allow(clippy::needless_lifetimes)] pub async fn wait_until<'a, T, F>( &self, mut guard: MutexGuard<'a, T>, @@ -213,6 +221,7 @@ impl Condvar { /// # /// # }) } /// ``` + #[allow(clippy::needless_lifetimes)] pub async fn wait_timeout<'a, T>( &self, guard: MutexGuard<'a, T>, diff --git a/tests/condvar.rs b/tests/condvar.rs index 70be8c233..60378ee1e 100644 --- a/tests/condvar.rs +++ b/tests/condvar.rs @@ -31,7 +31,7 @@ fn notify_all() { let mut tasks: Vec> = Vec::new(); let pair = Arc::new((Mutex::new(0u32), Condvar::new())); - for i in 0..10 { + for _ in 0..10 { let pair = pair.clone(); tasks.push(task::spawn(async move { let (m, c) = &*pair; @@ -57,6 +57,6 @@ fn notify_all() { t.await; } let count = m.lock().await; - assert!(*count == 11); + assert_eq!(11, *count); }) }