Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(layout)!: add parameters to Layout::new() #557

Merged
merged 1 commit into from
Nov 21, 2023
Merged

Conversation

joshka
Copy link
Member

@joshka joshka commented Oct 4, 2023

Adds a convenience function to create a layout with a direction and a
list of constraints which are the most common parameters that would be
generally configured using the builder pattern. The constraints can be
passed in as any iterator of constraints.

let layout = Layout::new(Direction::Horizontal, [
    Constraint::Percentage(50),
    Constraint::Percentage(50),
]);

BREAKING CHANGE:
Layout::new() now takes a direction and a list of constraints instead of
no arguments. This is a breaking change because it changes the signature
of the function. Layout::new() is also no longer const because it takes
an iterator of constraints.

Layout::new() was added in a recent release, so the amount of code broken by this is reasonably small. Tagging the owners of affected repos as a headsup:
https://github.com/search?q=ratatui+%22Layout%3A%3Anew%22&type=code

@codecov
Copy link

codecov bot commented Oct 4, 2023

Codecov Report

Merging #557 (d81cbef) into main (fbf1a45) will increase coverage by 0.09%.
Report is 5 commits behind head on main.
The diff coverage is 95.74%.

@@            Coverage Diff             @@
##             main     #557      +/-   ##
==========================================
+ Coverage   89.51%   89.61%   +0.09%     
==========================================
  Files          41       41              
  Lines       11557    11628      +71     
==========================================
+ Hits        10345    10420      +75     
+ Misses       1212     1208       -4     
Files Coverage Δ
src/layout.rs 98.81% <95.74%> (+0.56%) ⬆️

... and 1 file with indirect coverage changes

src/layout.rs Show resolved Hide resolved
Adds a convenience function to create a layout with a direction and a
list of constraints which are the most common parameters that would be
generally configured using the builder pattern. The constraints can be
passed in as any iterator of constraints.

```rust
let layout = Layout::new(Direction::Horizontal, [
    Constraint::Percentage(50),
    Constraint::Percentage(50),
]);
```

BREAKING CHANGE:
Layout::new() now takes a direction and a list of constraints instead of
no arguments. This is a breaking change because it changes the signature
of the function. Layout::new() is also no longer const because it takes
an iterator of constraints.
@joshka joshka merged commit 1e2f0be into main Nov 21, 2023
33 checks passed
@joshka joshka deleted the simplify-constraints branch November 21, 2023 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants