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): accept Into<Constraint> for constructors #744

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

joshka
Copy link
Member

@joshka joshka commented Jan 5, 2024

This allows Layout constructors to accept any type that implements
Into instead of just AsRef. This is useful when
you want to specify a fixed size for a layout, but don't want to
explicitly create a Constraint::Length yourself.

Layout::new(Direction::Vertical, [1, 2, 3]);
Layout::horizontal([1, 2, 3]);
Layout::vertical([1, 2, 3]);
Layout::default().constraints([1, 2, 3]);

Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (659460e) 92.3% compared to head (289ec88) 92.3%.
Report is 1 commits behind head on main.

❗ Current head 289ec88 differs from pull request most recent head e5033b8. Consider uploading reports for the commit e5033b8 to get more accurate results

Files Patch % Lines
src/layout/constraint.rs 50.0% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #744     +/-   ##
=======================================
- Coverage   92.3%   92.3%   -0.1%     
=======================================
  Files         52      52             
  Lines      14806   14811      +5     
=======================================
+ Hits       13672   13674      +2     
- Misses      1134    1137      +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joshka joshka force-pushed the layout-accept-into-constraint branch from a5abefe to 289ec88 Compare January 5, 2024 05:52
@joshka joshka marked this pull request as ready for review January 5, 2024 05:52
This allows Layout constructors to accept any type that implements
Into<Constraint> instead of just AsRef<Constraint>. This is useful when
you want to specify a fixed size for a layout, but don't want to
explicitly create a Constraint::Length yourself.

```rust
Layout::new(Direction::Vertical, [1, 2, 3]);
Layout::horizontal([1, 2, 3]);
Layout::vertical([1, 2, 3]);
Layout::default().constraints([1, 2, 3]);
```
@joshka joshka force-pushed the layout-accept-into-constraint branch from 289ec88 to e5033b8 Compare January 5, 2024 06:36
@joshka joshka merged commit 0494ee5 into main Jan 5, 2024
@joshka joshka deleted the layout-accept-into-constraint branch January 5, 2024 06:36
@kdheepak
Copy link
Collaborator

kdheepak commented Jan 5, 2024

@a-kenji feel free to provide feedback on what you think about this PR, even if it is merged! We'd definitely want to hear everyone's opinions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants