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:
parent
596ee58be8
commit
298ca5ff1b
6 changed files with 55 additions and 93 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue