From 1c26440f0bd8f7a002946524dd4d522ba9fb7f29 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 27 Jun 2023 22:46:04 +0200 Subject: Use `Option::filter` instead of `and_then` in `scrollable` --- widget/src/scrollable.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'widget/src/scrollable.rs') diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 5bc6914c..473124ca 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -1203,21 +1203,13 @@ impl Scrollbars { ) -> Self { let offset = state.offset(direction, bounds, content_bounds); - let show_scrollbar_x = direction.horizontal().and_then(|h| { - if content_bounds.width > bounds.width { - Some(h) - } else { - None - } - }); + let show_scrollbar_x = direction + .horizontal() + .filter(|_| content_bounds.width > bounds.width); - let show_scrollbar_y = direction.vertical().and_then(|v| { - if content_bounds.height > bounds.height { - Some(v) - } else { - None - } - }); + let show_scrollbar_y = direction + .vertical() + .filter(|_| content_bounds.height > bounds.height); let y_scrollbar = if let Some(vertical) = show_scrollbar_y { let Properties { -- cgit