Files
oak-gpui/crates
Marshall Bowers ec0cff0e1a Add map method to Components (#3210)
This PR adds a `map` method to the `Component` trait.

`map` is a fully-generalized form of `when`, as `when` can be expressed
in terms of `map`:

```rs
div().map(|this| if condition { then(this) } else { this })
```

This allows us to take advantage of Rust's pattern matching when
building up conditions:

```rs
// Before
div()
    .when(self.current_side == PanelSide::Left, |this| this.border_r())
    .when(self.current_side == PanelSide::Right, |this| {
        this.border_l()
    })
    .when(self.current_side == PanelSide::Bottom, |this| {
        this.border_b().w_full().h(current_size)
    })

// After
div()
    .map(|this| match self.current_side {
        PanelSide::Left => this.border_r(),
        PanelSide::Right => this.border_l(),
        PanelSide::Bottom => this.border_b().w_full().h(current_size),
    })
```

Release Notes:

- N/A
2023-11-02 11:39:40 -04:00
..
wip
2023-11-01 13:53:45 -06:00
2023-10-27 10:55:15 +02:00
2023-11-01 21:16:41 -06:00
2023-11-01 14:50:29 -04:00
2023-10-25 17:09:12 +02:00
2023-11-02 11:01:38 -04:00
wip
2023-11-01 13:53:45 -06:00
2023-11-02 09:47:21 +01:00
2023-11-01 13:53:45 -06:00
wip
2023-11-01 13:53:45 -06:00
2023-11-02 09:47:21 +01:00
wip
2023-11-01 13:53:45 -06:00
2023-10-30 12:56:23 -04:00
2023-11-01 21:19:06 -06:00
2023-11-01 15:31:37 -06:00
2023-11-01 21:54:10 -04:00
2023-11-01 16:13:53 -04:00
2023-11-01 22:01:59 -04:00
2023-11-02 11:39:40 -04:00
2023-10-27 10:55:15 +02:00
wip
2023-11-01 13:53:45 -06:00
2023-10-23 11:06:58 +02:00
2023-10-25 15:53:34 +02:00
2023-10-30 19:44:01 +01:00
2023-11-01 12:34:26 -04:00
2023-10-28 11:37:25 -04:00