Skip to content

Commit

Permalink
Make library more usable in a const context (#203)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
alice-i-cecile authored Jul 25, 2022
1 parent 226bf9f commit 034f064
Show file tree
Hide file tree
Showing 488 changed files with 589 additions and 553 deletions.
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ If you are developing on macOS this is easy to do through brew.
brew install chromedriver
```

If you are Ubuntu, you will have to install `openssl` first,
and then can follow [these instructions](https://tecadmin.net/setup-selenium-chromedriver-on-ubuntu/).
Be sure that your Chrome vesion matches the downloaded `chromedriver` version!

Once you have chromedriver installed and available in `PATH` you can re-generate all tests by running `cargo run --package gentest`. You should not manually update the tests in `tests/generated`. Instead, fix the script in `scripts/gentest/` and re-generate them. This can happen after a refactor. It can be helpful to commit the updated tests in a dedicated commit so that they can be easier to ignore during review.

To add a new test case add another HTML file to `/test_fixtures` following the current tests as a template for new tests.
Expand Down
3 changes: 3 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- Added `taffy::error::InvalidChild` Error type
- `taffy::node::Taffy.new_leaf()` which allows the creation of new leaf-nodes without having to supply a measure function
- Builder methods are now `const` where possible
- Several convenenience constants have been defined: notably `FlexboxLayout::DEFAULT`

### 0.2.0 Changed

Expand All @@ -24,6 +26,7 @@
- `taffy::error::InvalidChild` is now `taffy::error::TaffyError`
- `taffy::error::InvalidNode` has been removed and is now just a branch on the `TaffyError` enum
- `taffy::forest::Forest` has been merged into `taffy::node::Taffy` for a performance boost up to 90%
- `Size::undefined()` has been removed, use `Size::NONE` instead.

### 0.2.0 Fixed

Expand Down
4 changes: 2 additions & 2 deletions benches/complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn taffy_benchmarks(c: &mut Criterion) {
b.iter(|| {
let mut taffy = taffy::node::Taffy::new();
let root = build_deep_hierarchy(&mut taffy);
taffy.compute_layout(root, taffy::geometry::Size::undefined()).unwrap()
taffy.compute_layout(root, taffy::geometry::Size::NONE).unwrap()
})
});

Expand All @@ -117,7 +117,7 @@ fn taffy_benchmarks(c: &mut Criterion) {

b.iter(|| {
taffy.mark_dirty(root).unwrap();
taffy.compute_layout(root, taffy::geometry::Size::undefined()).unwrap()
taffy.compute_layout(root, taffy::geometry::Size::NONE).unwrap()
})
});
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/absolute_layout_align_items_center.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/absolute_layout_child_order.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/absolute_layout_no_size.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/absolute_layout_start_top_end_bottom.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/absolute_layout_within_border.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/align_baseline.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/align_baseline_child_multiline.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/align_baseline_nested_child.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/align_items_center.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/align_items_center_with_child_margin.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/align_items_center_with_child_top.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/align_items_flex_end.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/align_items_flex_start.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/align_items_min_max.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/align_items_stretch.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/align_self_baseline.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/align_self_center.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/align_self_flex_end.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/align_self_flex_start.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/border_center_child.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/border_flex_child.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/border_no_child.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/border_stretch_child.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benches/generated/child_min_max_width_flexing.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 034f064

Please sign in to comment.