Skip to content

Commit da086fb

Browse files
committed
Use Option::filter instead of and_then in scrollable
1 parent 159853f commit da086fb

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

widget/src/scrollable.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,21 +1203,13 @@ impl Scrollbars {
12031203
) -> Self {
12041204
let offset = state.offset(direction, bounds, content_bounds);
12051205

1206-
let show_scrollbar_x = direction.horizontal().and_then(|h| {
1207-
if content_bounds.width > bounds.width {
1208-
Some(h)
1209-
} else {
1210-
None
1211-
}
1212-
});
1206+
let show_scrollbar_x = direction
1207+
.horizontal()
1208+
.filter(|_| content_bounds.width > bounds.width);
12131209

1214-
let show_scrollbar_y = direction.vertical().and_then(|v| {
1215-
if content_bounds.height > bounds.height {
1216-
Some(v)
1217-
} else {
1218-
None
1219-
}
1220-
});
1210+
let show_scrollbar_y = direction
1211+
.vertical()
1212+
.filter(|_| content_bounds.height > bounds.height);
12211213

12221214
let y_scrollbar = if let Some(vertical) = show_scrollbar_y {
12231215
let Properties {

0 commit comments

Comments
 (0)