Skip to content

Commit

Permalink
Use Option::filter instead of and_then in scrollable
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Jun 27, 2023
1 parent 73e5967 commit 4dea939
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions widget/src/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4dea939

Please sign in to comment.