Skip to content

Commit

Permalink
feat(List)!: List::new now accepts `IntoIterator<Item = Into<ListIt…
Browse files Browse the repository at this point in the history
…em>>` (#672)

This allows to build list like

```
List::new(["Item 1", "Item 2"])
```

BREAKING CHANGE: `List::new` parameter type changed from `Into<Vec<ListItem<'a>>>`
to `IntoIterator<Item = Into<ListItem<'a>>>`
  • Loading branch information
Valentin271 authored Dec 8, 2023
1 parent 8bfd666 commit aef4956
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 23 deletions.
24 changes: 21 additions & 3 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ github with a [breaking change] label.
This is a quick summary of the sections below:

- Unreleased (0.24.1)
- `List::new()` now accepts `IntoIterator<Item = Into<ListItem<'a>>>`
- `Table::new()` now requires specifying the widths
-`Table::widths()` now accepts `IntoIterator<Item = AsRef<Constraint>>`
- `Table::widths()` now accepts `IntoIterator<Item = AsRef<Constraint>>`
- Layout::new() now accepts direction and constraint parameters
- The default `Tabs::highlight_style` is now `Style::new().reversed()`

Expand Down Expand Up @@ -40,6 +41,21 @@ This is a quick summary of the sections below:

## Unreleased (v0.24.1)

### `List::new()` now accepts `IntoIterator<Item = Into<ListItem<'a>>>` ([#672])

[#672]: https://github.com/ratatui-org/ratatui/pull/672

Previously `List::new()` took `Into<Vec<ListItem<'a>>>`. This change will throw a compilation
error for `IntoIterator`s with an indeterminate item (e.g. empty vecs).

E.g.

```rust
let list = List::new(vec![]);
// becomes
let list = List::default();
```

### The default `Tabs::highlight_style` is now `Style::new().reversed()` ([#635])

Previously the default highlight style for tabs was `Style::default()`, which meant that a `Tabs`
Expand All @@ -53,10 +69,12 @@ Previously the default highlight style for tabs was `Style::default()`, which me
widget in the default configuration would not show any indication of the selected tab.


### `Table::new()` now requires specifying the widths of the columrs (#664)
### `Table::new()` now requires specifying the widths of the columns (#664)

[#664]: https://github.com/ratatui-org/ratatui/pull/664

Previously `Table`s could be constructed without widths. In almost all cases this is an error.
A new widths parameter is now manadatory on `Table::new()`. Existing code of the form:
A new widths parameter is now mandatory on `Table::new()`. Existing code of the form:

```rust
Table::new(rows).widths(widths)
Expand Down
Loading

0 comments on commit aef4956

Please sign in to comment.