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
|
@ -119,9 +119,15 @@ impl Render for Toolbar {
|
|||
.when(has_right_items, |this| {
|
||||
this.child(
|
||||
h_flex()
|
||||
// We're using `flex_none` here to prevent some flickering that can occur when the
|
||||
// size of the left items container changes.
|
||||
.when_else(has_left_items, Div::flex_none, Div::flex_auto)
|
||||
.map(|el| {
|
||||
if has_left_items {
|
||||
// We're using `flex_none` here to prevent some flickering that can occur when the
|
||||
// size of the left items container changes.
|
||||
el.flex_none()
|
||||
} else {
|
||||
el.flex_auto()
|
||||
}
|
||||
})
|
||||
.justify_end()
|
||||
.children(self.right_items().map(|item| item.to_any())),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue