Skip to content

Commit 8b8b651

Browse files
committed
Fix clippy: option_map_unit_fn
1 parent fe6f087 commit 8b8b651

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/diskio/threaded.rs

+18-13
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,18 @@ impl<'a> Executor for Threaded<'a> {
115115
// items, and the download tracker's progress is confounded with
116116
// actual handling of data today, we synthesis a data buffer and
117117
// pretend to have bytes to deliver.
118-
self.notify_handler
119-
.map(|handler| handler(Notification::DownloadFinished));
120-
self.notify_handler
121-
.map(|handler| handler(Notification::DownloadPushUnits("iops")));
118+
if let Some(handler) = self.notify_handler {
119+
handler(Notification::DownloadFinished);
120+
}
121+
if let Some(handler) = self.notify_handler {
122+
handler(Notification::DownloadPushUnits("iops"));
123+
}
122124
let mut prev_files = self.n_files.load(Ordering::Relaxed);
123-
self.notify_handler.map(|handler| {
125+
if let Some(handler) = self.notify_handler {
124126
handler(Notification::DownloadContentLengthReceived(
125127
prev_files as u64,
126-
))
127-
});
128+
));
129+
}
128130
if prev_files > 50 {
129131
println!("{} deferred IO operations", prev_files);
130132
}
@@ -139,14 +141,17 @@ impl<'a> Executor for Threaded<'a> {
139141
prev_files = current_files;
140142
current_files = self.n_files.load(Ordering::Relaxed);
141143
let step_count = prev_files - current_files;
142-
self.notify_handler
143-
.map(|handler| handler(Notification::DownloadDataReceived(&buf[0..step_count])));
144+
if let Some(handler) = self.notify_handler {
145+
handler(Notification::DownloadDataReceived(&buf[0..step_count]));
146+
}
144147
}
145148
self.pool.join();
146-
self.notify_handler
147-
.map(|handler| handler(Notification::DownloadFinished));
148-
self.notify_handler
149-
.map(|handler| handler(Notification::DownloadPopUnits));
149+
if let Some(handler) = self.notify_handler {
150+
handler(Notification::DownloadFinished);
151+
}
152+
if let Some(handler) = self.notify_handler {
153+
handler(Notification::DownloadPopUnits);
154+
}
150155
// close the feedback channel so that blocking reads on it can
151156
// complete. send is atomic, and we know the threads completed from the
152157
// pool join, so this is race-free. It is possible that try_iter is safe

0 commit comments

Comments
 (0)