Skip to content

Commit aef4956

Browse files
authored
feat(List)!: List::new now accepts IntoIterator<Item = Into<ListItem>> (#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>>>`
1 parent 8bfd666 commit aef4956

File tree

3 files changed

+173
-23
lines changed

3 files changed

+173
-23
lines changed

BREAKING-CHANGES.md

+21-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ github with a [breaking change] label.
1111
This is a quick summary of the sections below:
1212

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

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

4142
## Unreleased (v0.24.1)
4243

44+
### `List::new()` now accepts `IntoIterator<Item = Into<ListItem<'a>>>` ([#672])
45+
46+
[#672]: https://github.com/ratatui-org/ratatui/pull/672
47+
48+
Previously `List::new()` took `Into<Vec<ListItem<'a>>>`. This change will throw a compilation
49+
error for `IntoIterator`s with an indeterminate item (e.g. empty vecs).
50+
51+
E.g.
52+
53+
```rust
54+
let list = List::new(vec![]);
55+
// becomes
56+
let list = List::default();
57+
```
58+
4359
### The default `Tabs::highlight_style` is now `Style::new().reversed()` ([#635])
4460

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

5571

56-
### `Table::new()` now requires specifying the widths of the columrs (#664)
72+
### `Table::new()` now requires specifying the widths of the columns (#664)
73+
74+
[#664]: https://github.com/ratatui-org/ratatui/pull/664
5775

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

6179
```rust
6280
Table::new(rows).widths(widths)

0 commit comments

Comments
 (0)