Skip to content

Commit b20d048

Browse files
committed
Fix build
1 parent 80aece0 commit b20d048

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Diff for: src/sync/condvar.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct WaitTimeoutResult(bool);
1515
/// not
1616
impl WaitTimeoutResult {
1717
/// Returns `true` if the wait was known to have timed out.
18-
pub fn timed_out(&self) -> bool {
18+
pub fn timed_out(self) -> bool {
1919
self.0
2020
}
2121
}
@@ -62,6 +62,12 @@ pub struct Condvar {
6262
blocked: std::sync::Mutex<Slab<Option<Waker>>>,
6363
}
6464

65+
impl Default for Condvar {
66+
fn default() -> Self {
67+
Condvar::new()
68+
}
69+
}
70+
6571
impl Condvar {
6672
/// Creates a new condition variable
6773
///
@@ -111,6 +117,7 @@ impl Condvar {
111117
/// }
112118
/// # }) }
113119
/// ```
120+
#[allow(clippy::needless_lifetimes)]
114121
pub async fn wait<'a, T>(&self, guard: MutexGuard<'a, T>) -> MutexGuard<'a, T> {
115122
let mutex = guard_lock(&guard);
116123

@@ -161,6 +168,7 @@ impl Condvar {
161168
/// # }) }
162169
/// ```
163170
#[cfg(feature = "unstable")]
171+
#[allow(clippy::needless_lifetimes)]
164172
pub async fn wait_until<'a, T, F>(
165173
&self,
166174
mut guard: MutexGuard<'a, T>,
@@ -213,6 +221,7 @@ impl Condvar {
213221
/// #
214222
/// # }) }
215223
/// ```
224+
#[allow(clippy::needless_lifetimes)]
216225
pub async fn wait_timeout<'a, T>(
217226
&self,
218227
guard: MutexGuard<'a, T>,

Diff for: tests/condvar.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn notify_all() {
3131
let mut tasks: Vec<JoinHandle<()>> = Vec::new();
3232
let pair = Arc::new((Mutex::new(0u32), Condvar::new()));
3333

34-
for i in 0..10 {
34+
for _ in 0..10 {
3535
let pair = pair.clone();
3636
tasks.push(task::spawn(async move {
3737
let (m, c) = &*pair;
@@ -57,6 +57,6 @@ fn notify_all() {
5757
t.await;
5858
}
5959
let count = m.lock().await;
60-
assert!(*count == 11);
60+
assert_eq!(11, *count);
6161
})
6262
}

0 commit comments

Comments
 (0)