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

Make library more usable in a const context #203

Merged
merged 9 commits into from
Jul 25, 2022

Conversation

alice-i-cecile
Copy link
Collaborator

@alice-i-cecile alice-i-cecile commented Jul 22, 2022

Objective

When working with Style in Bevy, I noticed that a common pattern was to use ..Default::default() on what is now FlexboxLayout.

However, trait methods can't be constant in Rust (yet), so this can't be used to define new constant layout styles.

Changes:

  1. Add FlexboxLayout::DEFAULT.
  2. Clean up uses of constants.
  3. Make builder patterns constant where possible.

Context

Upstream tracking issue for the Rustl limitation: rust-lang/rust#63065.

Some builder methods could not be made const because of orlp/slotmap#85.

@alice-i-cecile alice-i-cecile added usability Make the library more comfortable to use code quality Make the code cleaner or prettier. labels Jul 22, 2022
@alice-i-cecile
Copy link
Collaborator Author

Going to leave this up for a couple days; changes are trivial but if you see this feel free to review.

RELEASES.md Outdated Show resolved Hide resolved
@alice-i-cecile alice-i-cecile enabled auto-merge (squash) July 25, 2022 20:03
@alice-i-cecile alice-i-cecile merged commit 034f064 into DioxusLabs:main Jul 25, 2022
jkelleyrtp pushed a commit that referenced this pull request Oct 10, 2022
* Add FlexboxLayout::DEFAULT constant

* Make constructors const where possible

* Use Size::NONE instead of Size::undefined()

* Stick with Layout::new

* More advice on setting up chromedriver

* More const builders

* Update tests

* Fix find-and-replace error in CHANGELOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Make the code cleaner or prettier. usability Make the library more comfortable to use
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants