Prefer .map for conditionals with else conditions (#15118)

This PR updates instances where we were using `.when_else` and
`.when_else_some` to use `.map` with a conditional inside.

This allows us to avoid reinventing Rust's syntax for conditionals and
(IMO) makes the code easier to read.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-07-24 17:09:07 -04:00 committed by GitHub
parent 596ee58be8
commit 298ca5ff1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 55 additions and 93 deletions

View file

@ -342,11 +342,13 @@ impl Render for LegacySettingsMenu {
.max_w_96()
.max_h_2_3()
.px_2()
.when_else(
is_empty,
|empty| empty.py_1(),
|not_empty| not_empty.pt_0().pb_1(),
)
.map(|el| {
if is_empty {
el.py_1()
} else {
el.pt_0().pb_1()
}
})
.gap_1()
.when(is_empty, |this| {
this.child(Label::new("No settings found").color(Color::Muted))