Enable clippy::option_map_unit_fn (#8751)

This PR enables the
[`clippy::option_map_unit_fn`](https://rust-lang.github.io/rust-clippy/master/index.html#/option_map_unit_fn)
rule and fixes the outstanding violations.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-03-02 22:08:37 -05:00 committed by GitHub
parent d19957b705
commit ea68f86476
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 75 additions and 55 deletions

View file

@ -1433,16 +1433,20 @@ impl Pane {
"Close Clean",
Some(Box::new(CloseCleanItems)),
cx.handler_for(&pane, move |pane, cx| {
pane.close_clean_items(&CloseCleanItems, cx)
.map(|task| task.detach_and_log_err(cx));
if let Some(task) = pane.close_clean_items(&CloseCleanItems, cx) {
task.detach_and_log_err(cx)
}
}),
)
.entry(
"Close All",
Some(Box::new(CloseAllItems { save_intent: None })),
cx.handler_for(&pane, |pane, cx| {
pane.close_all_items(&CloseAllItems { save_intent: None }, cx)
.map(|task| task.detach_and_log_err(cx));
if let Some(task) =
pane.close_all_items(&CloseAllItems { save_intent: None }, cx)
{
task.detach_and_log_err(cx)
}
}),
);
@ -1783,42 +1787,49 @@ impl Render for Pane {
}))
.on_action(
cx.listener(|pane: &mut Self, action: &CloseActiveItem, cx| {
pane.close_active_item(action, cx)
.map(|task| task.detach_and_log_err(cx));
if let Some(task) = pane.close_active_item(action, cx) {
task.detach_and_log_err(cx)
}
}),
)
.on_action(
cx.listener(|pane: &mut Self, action: &CloseInactiveItems, cx| {
pane.close_inactive_items(action, cx)
.map(|task| task.detach_and_log_err(cx));
if let Some(task) = pane.close_inactive_items(action, cx) {
task.detach_and_log_err(cx)
}
}),
)
.on_action(
cx.listener(|pane: &mut Self, action: &CloseCleanItems, cx| {
pane.close_clean_items(action, cx)
.map(|task| task.detach_and_log_err(cx));
if let Some(task) = pane.close_clean_items(action, cx) {
task.detach_and_log_err(cx)
}
}),
)
.on_action(
cx.listener(|pane: &mut Self, action: &CloseItemsToTheLeft, cx| {
pane.close_items_to_the_left(action, cx)
.map(|task| task.detach_and_log_err(cx));
if let Some(task) = pane.close_items_to_the_left(action, cx) {
task.detach_and_log_err(cx)
}
}),
)
.on_action(
cx.listener(|pane: &mut Self, action: &CloseItemsToTheRight, cx| {
pane.close_items_to_the_right(action, cx)
.map(|task| task.detach_and_log_err(cx));
if let Some(task) = pane.close_items_to_the_right(action, cx) {
task.detach_and_log_err(cx)
}
}),
)
.on_action(cx.listener(|pane: &mut Self, action: &CloseAllItems, cx| {
pane.close_all_items(action, cx)
.map(|task| task.detach_and_log_err(cx));
if let Some(task) = pane.close_all_items(action, cx) {
task.detach_and_log_err(cx)
}
}))
.on_action(
cx.listener(|pane: &mut Self, action: &CloseActiveItem, cx| {
pane.close_active_item(action, cx)
.map(|task| task.detach_and_log_err(cx));
if let Some(task) = pane.close_active_item(action, cx) {
task.detach_and_log_err(cx)
}
}),
)
.on_action(

View file

@ -1627,8 +1627,11 @@ impl Workspace {
action: &CloseInactiveTabsAndPanes,
cx: &mut ViewContext<Self>,
) {
self.close_all_internal(true, action.save_intent.unwrap_or(SaveIntent::Close), cx)
.map(|task| task.detach_and_log_err(cx));
if let Some(task) =
self.close_all_internal(true, action.save_intent.unwrap_or(SaveIntent::Close), cx)
{
task.detach_and_log_err(cx)
}
}
pub fn close_all_items_and_panes(
@ -1636,8 +1639,11 @@ impl Workspace {
action: &CloseAllItemsAndPanes,
cx: &mut ViewContext<Self>,
) {
self.close_all_internal(false, action.save_intent.unwrap_or(SaveIntent::Close), cx)
.map(|task| task.detach_and_log_err(cx));
if let Some(task) =
self.close_all_internal(false, action.save_intent.unwrap_or(SaveIntent::Close), cx)
{
task.detach_and_log_err(cx)
}
}
fn close_all_internal(
@ -2599,8 +2605,9 @@ impl Workspace {
if Some(leader_id) == self.unfollow(&pane, cx) {
return;
}
self.start_following(leader_id, cx)
.map(|task| task.detach_and_log_err(cx));
if let Some(task) = self.start_following(leader_id, cx) {
task.detach_and_log_err(cx)
}
}
pub fn follow(&mut self, leader_id: PeerId, cx: &mut ViewContext<Self>) {
@ -2642,8 +2649,9 @@ impl Workspace {
}
// Otherwise, follow.
self.start_following(leader_id, cx)
.map(|task| task.detach_and_log_err(cx));
if let Some(task) = self.start_following(leader_id, cx) {
task.detach_and_log_err(cx)
}
}
pub fn unfollow(&mut self, pane: &View<Pane>, cx: &mut ViewContext<Self>) -> Option<PeerId> {