diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 770677021..fc116ce83 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,6 +34,8 @@ 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 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. +`cargo gentest` generates log events that can be viewed by setting the [`RUST_LOG`](https://docs.rs/env_logger/0.10.0/env_logger/#enabling-logging) env variable. E.g. `export RUST_LOG="info"`. + To add a new test case add another HTML file to `/test_fixtures` following the current tests as a template for new tests. **Note: test fixtures (HTML files in the `text_fixtures` directory) that begin with an "x" are considered disabled, and the test generation script will not generate a test for them (and as the test generation script overwrites the entire directory when generating tests, this means that prefixing an existing test with an "x" and then running the test generation script will delete that test)** diff --git a/README.md b/README.md index 7411cff6d..86434c991 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ let header_node = taffy size: Size { width: length(800.0), height: length(100.0) }, ..Default::default() }, - ).unwrap(); + ); let body_node = taffy .new_leaf( @@ -40,7 +40,7 @@ let body_node = taffy flex_grow: 1.0, ..Default::default() }, - ).unwrap(); + ); let root_node = taffy .new_with_children( @@ -51,18 +51,18 @@ let root_node = taffy }, &[header_node, body_node], ) - .unwrap(); + ; // Call compute_layout on the root of your tree to run the layout algorithm -taffy.compute_layout(root_node, Size::MAX_CONTENT).unwrap(); +taffy.compute_layout(root_node, Size::MAX_CONTENT); // Inspect the computed layout using taffy.layout -assert_eq!(taffy.layout(root_node).unwrap().size.width, 800.0); -assert_eq!(taffy.layout(root_node).unwrap().size.height, 600.0); -assert_eq!(taffy.layout(header_node).unwrap().size.width, 800.0); -assert_eq!(taffy.layout(header_node).unwrap().size.height, 100.0); -assert_eq!(taffy.layout(body_node).unwrap().size.width, 800.0); -assert_eq!(taffy.layout(body_node).unwrap().size.height, 500.0); // This value was not set explicitly, but was computed by Taffy +assert_eq!(taffy.layout(root_node).size.width, 800.0); +assert_eq!(taffy.layout(root_node).size.height, 600.0); +assert_eq!(taffy.layout(header_node).size.width, 800.0); +assert_eq!(taffy.layout(header_node).size.height, 100.0); +assert_eq!(taffy.layout(body_node).size.width, 800.0); +assert_eq!(taffy.layout(body_node).size.height, 500.0); // This value was not set explicitly, but was computed by Taffy ``` diff --git a/RELEASES.md b/RELEASES.md index ad42aaf45..e36f332a1 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4,8 +4,31 @@ ### Breaking +#### Fewer unwraps. + +Infallible `Taffy` methods that have previously returned `TaffyResult` will simply return the `Ok` value only. +This change affects the following methods: + +- `Taffy::add_child` +- `Taffy::child_count` +- `Taffy::children` +- `Taffy::compute_layout` +- `Taffy::dirty` +- `Taffy::layout` +- `Taffy::mark_dirty` +- `Taffy::new_leaf_with_measure` +- `Taffy::new_with_children` +- `Taffy::remove` +- `Taffy::set_children` +- `Taffy::set_measure` +- `Taffy::set_style` +- `Taffy::style` +- `Taffy::new_leaf` + +#### Replace `Points` with `Length` + Many APIs have been renamed to replace `points` or `Points` with `length` or `Length`. -This new name better describes one-dimentional measure of space in some unspecified unit +This new name better describes one-dimensional measure of space in some unspecified unit which is often unrelated to the PostScript point or the CSS `pt` unit. This also removes a misleading similarity with the 2D `Point`, diff --git a/benches/benches/flexbox.rs b/benches/benches/flexbox.rs index 393bb996e..c391030c0 100644 --- a/benches/benches/flexbox.rs +++ b/benches/benches/flexbox.rs @@ -15,7 +15,7 @@ use yoga_helpers::yg; /// Build a random leaf node fn build_random_leaf(taffy: &mut Taffy, rng: &mut ChaCha8Rng) -> NodeId { - taffy.new_with_children(Style::random(rng), &[]).unwrap() + taffy.new_with_children(Style::random(rng), &[]) } /// A tree with many children that have shallow depth @@ -29,13 +29,13 @@ fn build_taffy_flat_hierarchy(total_node_count: u32) -> (Taffy, NodeId) { let sub_children_count = rng.gen_range(1..=4); let sub_children: Vec = (0..sub_children_count).map(|_| build_random_leaf(&mut taffy, &mut rng)).collect(); - let node = taffy.new_with_children(Style::random(&mut rng), &sub_children).unwrap(); + let node = taffy.new_with_children(Style::random(&mut rng), &sub_children); children.push(node); node_count += 1 + sub_children_count; } - let root = taffy.new_with_children(Style::DEFAULT, children.as_slice()).unwrap(); + let root = taffy.new_with_children(Style::DEFAULT, children.as_slice()); (taffy, root) } @@ -68,11 +68,11 @@ fn build_taffy_deep_hierarchy(node_count: u32, branching_factor: u32) -> (Taffy, let mut build_leaf_node = |taffy: &mut Taffy| build_random_leaf(taffy, &mut rng); let mut rng = ChaCha8Rng::seed_from_u64(12345); let mut build_flex_node = - |taffy: &mut Taffy, children: Vec| taffy.new_with_children(Style::random(&mut rng), &children).unwrap(); + |taffy: &mut Taffy, children: Vec| taffy.new_with_children(Style::random(&mut rng), &children); let mut taffy = Taffy::new(); let tree = build_deep_tree(&mut taffy, node_count, branching_factor, &mut build_leaf_node, &mut build_flex_node); - let root = taffy.new_with_children(Style::DEFAULT, &tree).unwrap(); + let root = taffy.new_with_children(Style::DEFAULT, &tree); (taffy, root) } @@ -101,13 +101,13 @@ fn build_taffy_huge_nested_hierarchy(node_count: u32, branching_factor: u32) -> flex_grow: 1.0, ..Default::default() }; - let mut build_leaf_node = |taffy: &mut Taffy| taffy.new_leaf(style.clone()).unwrap(); + let mut build_leaf_node = |taffy: &mut Taffy| taffy.new_leaf(style.clone()); let mut build_flex_node = - |taffy: &mut Taffy, children: Vec| taffy.new_with_children(style.clone(), &children).unwrap(); + |taffy: &mut Taffy, children: Vec| taffy.new_with_children(style.clone(), &children); let mut taffy = Taffy::new(); let tree = build_deep_tree(&mut taffy, node_count, branching_factor, &mut build_leaf_node, &mut build_flex_node); - let root = taffy.new_with_children(Style::DEFAULT, &tree).unwrap(); + let root = taffy.new_with_children(Style::DEFAULT, &tree); (taffy, root) } @@ -159,7 +159,7 @@ fn taffy_benchmarks(c: &mut Criterion) { group.bench_with_input(BenchmarkId::new("Taffy", node_count), node_count, |b, &node_count| { b.iter_batched( || build_taffy_huge_nested_hierarchy(node_count, 10), - |(mut taffy, root)| taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(), + |(mut taffy, root)| taffy.compute_layout(root, Size::MAX_CONTENT), criterion::BatchSize::SmallInput, ) }); @@ -186,7 +186,7 @@ fn taffy_benchmarks(c: &mut Criterion) { group.bench_with_input(benchmark_id, node_count, |b, &node_count| { b.iter_batched( || build_taffy_flat_hierarchy(node_count), - |(mut taffy, root)| taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(), + |(mut taffy, root)| taffy.compute_layout(root, Size::MAX_CONTENT), criterion::BatchSize::SmallInput, ) }); @@ -211,7 +211,7 @@ fn taffy_benchmarks(c: &mut Criterion) { group.bench_with_input(BenchmarkId::new(format!("Taffy {label}"), node_count), node_count, |b, &node_count| { b.iter_batched( || build_taffy_deep_hierarchy(node_count, 2), - |(mut taffy, root)| taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(), + |(mut taffy, root)| taffy.compute_layout(root, Size::MAX_CONTENT), criterion::BatchSize::SmallInput, ) }); @@ -234,7 +234,7 @@ fn taffy_benchmarks(c: &mut Criterion) { group.bench_with_input(BenchmarkId::new("Taffy", node_count), node_count, |b, &node_count| { b.iter_batched( || build_taffy_deep_hierarchy(node_count, 2), - |(mut taffy, root)| taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(), + |(mut taffy, root)| taffy.compute_layout(root, Size::MAX_CONTENT), criterion::BatchSize::SmallInput, ) }); diff --git a/benches/benches/grid.rs b/benches/benches/grid.rs index 19f74362f..973394157 100644 --- a/benches/benches/grid.rs +++ b/benches/benches/grid.rs @@ -8,7 +8,7 @@ use taffy::style::Style; /// Build a random leaf node fn build_random_leaf(taffy: &mut Taffy, _rng: &mut ChaCha8Rng) -> NodeId { - taffy.new_with_children(Style { size: length(20.0), ..Default::default() }, &[]).unwrap() + taffy.new_with_children(Style { size: length(20.0), ..Default::default() }, &[]) } fn random_grid_track(rng: &mut R) -> TrackSizingFunction { @@ -54,8 +54,7 @@ fn build_grid_flat_hierarchy(col_count: usize, row_count: usize) -> (Taffy, Node let children: Vec<_> = iter::from_fn(|| Some(build_random_leaf(&mut taffy, &mut rng))).take(col_count * row_count).collect(); - let root = taffy.new_with_children(style, children.as_slice()).unwrap(); - (taffy, root) + let root = taffy.new_with_children(style, children.as_slice())(taffy, root); } /// A helper function to recursively construct a deep tree @@ -91,12 +90,12 @@ fn build_taffy_deep_grid_hierarchy(levels: usize, track_count: usize) -> (Taffy, let mut build_leaf_node = |taffy: &mut Taffy| build_random_leaf(taffy, &mut rng); let mut rng = ChaCha8Rng::seed_from_u64(12345); let mut build_flex_node = |taffy: &mut Taffy, children: Vec| { - taffy.new_with_children(random_nxn_grid_style(&mut rng, track_count), &children).unwrap() + taffy.new_with_children(random_nxn_grid_style(&mut rng, track_count), &children) }; let mut taffy = Taffy::new(); let tree = build_deep_grid_tree(&mut taffy, levels, track_count, &mut build_leaf_node, &mut build_flex_node); - let root = taffy.new_with_children(Style::DEFAULT, &tree).unwrap(); + let root = taffy.new_with_children(Style::DEFAULT, &tree); (taffy, root) } @@ -110,7 +109,7 @@ fn taffy_benchmarks(c: &mut Criterion) { |b, &track_count| { b.iter_batched( || build_grid_flat_hierarchy(track_count, track_count), - |(mut taffy, root)| taffy.compute_layout(root, length(12000.0)).unwrap(), + |(mut taffy, root)| taffy.compute_layout(root, length(12000.0)), criterion::BatchSize::SmallInput, ) }, @@ -128,7 +127,7 @@ fn taffy_benchmarks(c: &mut Criterion) { |b, &(levels, tracks)| { b.iter_batched( || build_taffy_deep_grid_hierarchy(levels, tracks), - |(mut taffy, root)| taffy.compute_layout(root, length(12000.0)).unwrap(), + |(mut taffy, root)| taffy.compute_layout(root, length(12000.0)), criterion::BatchSize::SmallInput, ) }, @@ -142,7 +141,7 @@ fn taffy_benchmarks(c: &mut Criterion) { group.bench_with_input(BenchmarkId::new("1x1", levels), levels, |b, &levels| { b.iter_batched( || build_taffy_deep_grid_hierarchy(levels, 1), - |(mut taffy, root)| taffy.compute_layout(root, max_content()).unwrap(), + |(mut taffy, root)| taffy.compute_layout(root, max_content()), criterion::BatchSize::SmallInput, ) }); diff --git a/benches/benches/tree_creation.rs b/benches/benches/tree_creation.rs index 0c2178d50..0657c2969 100644 --- a/benches/benches/tree_creation.rs +++ b/benches/benches/tree_creation.rs @@ -14,7 +14,7 @@ use yoga_helpers::yg; /// Build a random leaf node fn build_random_leaf(taffy: &mut Taffy) -> NodeId { - taffy.new_with_children(Style::DEFAULT, &[]).unwrap() + taffy.new_with_children(Style::DEFAULT, &[]) } /// A tree with many children that have shallow depth @@ -27,13 +27,13 @@ fn build_taffy_flat_hierarchy(total_node_count: u32, use_with_capacity: bool) -> while node_count < total_node_count { let sub_children_count = rng.gen_range(1..=4); let sub_children: Vec = (0..sub_children_count).map(|_| build_random_leaf(&mut taffy)).collect(); - let node = taffy.new_with_children(Style::DEFAULT, &sub_children).unwrap(); + let node = taffy.new_with_children(Style::DEFAULT, &sub_children); children.push(node); node_count += 1 + sub_children_count; } - let root = taffy.new_with_children(Style::DEFAULT, children.as_slice()).unwrap(); + let root = taffy.new_with_children(Style::DEFAULT, children.as_slice()); (taffy, root) } diff --git a/examples/basic.rs b/examples/basic.rs index 888fd8164..843ddc376 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -1,12 +1,12 @@ use taffy::prelude::*; -fn main() -> Result<(), taffy::TaffyError> { +fn main() { let mut taffy = Taffy::new(); let child = taffy.new_leaf(Style { size: Size { width: Dimension::Percent(0.5), height: Dimension::Auto }, ..Default::default() - })?; + }); let node = taffy.new_with_children( Style { @@ -15,18 +15,14 @@ fn main() -> Result<(), taffy::TaffyError> { ..Default::default() }, &[child], - )?; + ); - taffy.compute_layout( - node, - Size { height: AvailableSpace::Definite(100.0), width: AvailableSpace::Definite(100.0) }, - )?; + taffy + .compute_layout(node, Size { height: AvailableSpace::Definite(100.0), width: AvailableSpace::Definite(100.0) }); // or just use undefined for 100 x 100 // taffy.compute_layout(node, Size::NONE)?; - println!("node: {:#?}", taffy.layout(node)?); - println!("child: {:#?}", taffy.layout(child)?); - - Ok(()) + println!("node: {:#?}", taffy.layout(node)); + println!("child: {:#?}", taffy.layout(child)); } diff --git a/examples/flexbox_gap.rs b/examples/flexbox_gap.rs index 0616527c6..11829884c 100644 --- a/examples/flexbox_gap.rs +++ b/examples/flexbox_gap.rs @@ -3,22 +3,20 @@ use taffy::prelude::*; // Creates three 20px x 20px children, evenly spaced 10px apart from each other // Thus the container is 80px x 20px. -fn main() -> Result<(), taffy::TaffyError> { +fn main() { let mut taffy = Taffy::new(); let child_style = Style { size: Size { width: length(20.0), height: length(20.0) }, ..Default::default() }; - let child0 = taffy.new_leaf(child_style.clone())?; - let child1 = taffy.new_leaf(child_style.clone())?; - let child2 = taffy.new_leaf(child_style.clone())?; + let child0 = taffy.new_leaf(child_style.clone()); + let child1 = taffy.new_leaf(child_style.clone()); + let child2 = taffy.new_leaf(child_style.clone()); let root = taffy.new_with_children( Style { gap: Size { width: length(10.0), height: zero() }, ..Default::default() }, &[child0, child1, child2], - )?; + ); // Compute layout and print result - taffy.compute_layout(root, Size::MAX_CONTENT)?; + taffy.compute_layout(root, Size::MAX_CONTENT); taffy::util::print_tree(&taffy, root); - - Ok(()) } diff --git a/examples/grid_holy_grail.rs b/examples/grid_holy_grail.rs index 1c95a9238..8a17d6217 100644 --- a/examples/grid_holy_grail.rs +++ b/examples/grid_holy_grail.rs @@ -16,7 +16,7 @@ fn default() -> T { } #[cfg(feature = "grid")] -fn main() -> Result<(), taffy::TaffyError> { +fn main() { use taffy::prelude::*; let mut taffy = Taffy::new(); @@ -31,18 +31,16 @@ fn main() -> Result<(), taffy::TaffyError> { }; // Define the child nodes - let header = taffy.new_leaf(Style { grid_row: line(1), grid_column: span(3), ..default() })?; - let left_sidebar = taffy.new_leaf(Style { grid_row: line(2), grid_column: line(1), ..default() })?; - let content_area = taffy.new_leaf(Style { grid_row: line(2), grid_column: line(2), ..default() })?; - let right_sidebar = taffy.new_leaf(Style { grid_row: line(2), grid_column: line(3), ..default() })?; - let footer = taffy.new_leaf(Style { grid_row: line(3), grid_column: span(3), ..default() })?; + let header = taffy.new_leaf(Style { grid_row: line(1), grid_column: span(3), ..default() }); + let left_sidebar = taffy.new_leaf(Style { grid_row: line(2), grid_column: line(1), ..default() }); + let content_area = taffy.new_leaf(Style { grid_row: line(2), grid_column: line(2), ..default() }); + let right_sidebar = taffy.new_leaf(Style { grid_row: line(2), grid_column: line(3), ..default() }); + let footer = taffy.new_leaf(Style { grid_row: line(3), grid_column: span(3), ..default() }); // Create the container with the children - let root = taffy.new_with_children(root_style, &[header, left_sidebar, content_area, right_sidebar, footer])?; + let root = taffy.new_with_children(root_style, &[header, left_sidebar, content_area, right_sidebar, footer]); // Compute layout and print result - taffy.compute_layout(root, Size { width: length(800.0), height: length(600.0) })?; + taffy.compute_layout(root, Size { width: length(800.0), height: length(600.0) }); taffy::util::print_tree(&taffy, root); - - Ok(()) } diff --git a/examples/nested.rs b/examples/nested.rs index 1e0d6bbde..bafeb684c 100644 --- a/examples/nested.rs +++ b/examples/nested.rs @@ -1,13 +1,13 @@ use taffy::prelude::*; -fn main() -> Result<(), taffy::TaffyError> { +fn main() { let mut taffy = Taffy::new(); // left let child_t1 = taffy.new_leaf(Style { size: Size { width: Dimension::Length(5.0), height: Dimension::Length(5.0) }, ..Default::default() - })?; + }); let div1 = taffy.new_with_children( Style { @@ -16,13 +16,13 @@ fn main() -> Result<(), taffy::TaffyError> { ..Default::default() }, &[child_t1], - )?; + ); // right let child_t2 = taffy.new_leaf(Style { size: Size { width: Dimension::Length(5.0), height: Dimension::Length(5.0) }, ..Default::default() - })?; + }); let div2 = taffy.new_with_children( Style { @@ -31,25 +31,21 @@ fn main() -> Result<(), taffy::TaffyError> { ..Default::default() }, &[child_t2], - )?; + ); let container = taffy.new_with_children( Style { size: Size { width: Dimension::Percent(1.0), height: Dimension::Percent(1.0) }, ..Default::default() }, &[div1, div2], - )?; + ); taffy.compute_layout( container, Size { height: AvailableSpace::Definite(100.0), width: AvailableSpace::Definite(100.0) }, - )?; + ); - println!("node: {:#?}", taffy.layout(container)?); - - println!("div1: {:#?}", taffy.layout(div1)?); - println!("div2: {:#?}", taffy.layout(div2)?); - - println!("child1: {:#?}", taffy.layout(child_t1)?); - println!("child2: {:#?}", taffy.layout(child_t2)?); - - Ok(()) + println!("node: {:#?}", taffy.layout(container)); + println!("div1: {:#?}", taffy.layout(div1)); + println!("div2: {:#?}", taffy.layout(div2)); + println!("child1: {:#?}", taffy.layout(child_t1)); + println!("child2: {:#?}", taffy.layout(child_t2)); } diff --git a/scripts/gentest/src/main.rs b/scripts/gentest/src/main.rs index 3d541c4a8..9ce81a0ce 100644 --- a/scripts/gentest/src/main.rs +++ b/scripts/gentest/src/main.rs @@ -157,7 +157,7 @@ fn generate_test(name: impl AsRef, description: &Value) -> TokenStream { let mut taffy = taffy::Taffy::new(); #set_rounding_mode #node_description - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); @@ -191,7 +191,7 @@ fn generate_assertions(ident: &str, node: &Value, use_rounding: bool) -> TokenSt if use_rounding { quote!( - let Layout { size, location, .. } = taffy.layout(#ident).unwrap(); + let Layout { size, location, .. } = taffy.layout(#ident); assert_eq!(size.width, #width, "width of node {:?}. Expected {}. Actual {}", #ident, #width, size.width); assert_eq!(size.height, #height, "height of node {:?}. Expected {}. Actual {}", #ident, #height, size.height); assert_eq!(location.x, #x, "x of node {:?}. Expected {}. Actual {}", #ident, #x, location.x); @@ -201,7 +201,7 @@ fn generate_assertions(ident: &str, node: &Value, use_rounding: bool) -> TokenSt ) } else { quote!( - let Layout { size, location, .. } = taffy.layout(#ident).unwrap(); + let Layout { size, location, .. } = taffy.layout(#ident); assert!(size.width - #width < 0.1, "width of node {:?}. Expected {}. Actual {}", #ident, #width, size.width); assert!(size.height - #height < 0.1, "height of node {:?}. Expected {}. Actual {}", #ident, #height, size.height); assert!(location.x - #x < 0.1, "x of node {:?}. Expected {}. Actual {}", #ident, #x, location.x); @@ -606,12 +606,12 @@ fn generate_node(ident: &str, node: &Value) -> TokenStream { if has_children { quote!( #children_body - let #ident = taffy.new_with_children(#style,#children).unwrap(); + let #ident = taffy.new_with_children(#style,#children); ) } else if measure_func.is_some() { - quote!(let #ident = taffy.new_leaf_with_measure(#style,#measure_func,).unwrap();) + quote!(let #ident = taffy.new_leaf_with_measure(#style,#measure_func,);) } else { - quote!(let #ident = taffy.new_leaf(#style).unwrap();) + quote!(let #ident = taffy.new_leaf(#style);) } } diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs index 6f61cb78c..ffe6818f7 100644 --- a/src/compute/flexbox.rs +++ b/src/compute/flexbox.rs @@ -2120,12 +2120,12 @@ mod tests { let mut tree = Taffy::with_capacity(16); let style = Style::default(); - let node_id = tree.new_leaf(style.clone()).unwrap(); + let node_id = tree.new_leaf(style.clone()); let node_size = Size::NONE; let parent_size = Size::NONE; - let constants = super::compute_constants(tree.style(node_id).unwrap(), node_size, parent_size); + let constants = super::compute_constants(tree.style(node_id), node_size, parent_size); assert!(constants.dir == style.flex_direction); assert!(constants.is_row == style.flex_direction.is_row()); diff --git a/src/compute/mod.rs b/src/compute/mod.rs index 5113839e8..0b7f578bd 100644 --- a/src/compute/mod.rs +++ b/src/compute/mod.rs @@ -118,29 +118,26 @@ mod tests { let style: Style = Style { display: Display::Flex, size: Size::from_lengths(50.0, 50.0), ..Default::default() }; - let grandchild_00 = taffy.new_leaf(style.clone()).unwrap(); - let grandchild_01 = taffy.new_leaf(style.clone()).unwrap(); - let child_00 = taffy.new_with_children(style.clone(), &[grandchild_00, grandchild_01]).unwrap(); + let grandchild_00 = taffy.new_leaf(style.clone()); + let grandchild_01 = taffy.new_leaf(style.clone()); + let child_00 = taffy.new_with_children(style.clone(), &[grandchild_00, grandchild_01]); - let grandchild_02 = taffy.new_leaf(style.clone()).unwrap(); - let child_01 = taffy.new_with_children(style.clone(), &[grandchild_02]).unwrap(); + let grandchild_02 = taffy.new_leaf(style.clone()); + let child_01 = taffy.new_with_children(style.clone(), &[grandchild_02]); - let root = taffy - .new_with_children( - Style { display: Display::None, size: Size::from_lengths(50.0, 50.0), ..Default::default() }, - &[child_00, child_01], - ) - .unwrap(); + let root = taffy.new_with_children( + Style { display: Display::None, size: Size::from_lengths(50.0, 50.0), ..Default::default() }, + &[child_00, child_01], + ); - perform_hidden_layout(&mut taffy, root.into()); + perform_hidden_layout(&mut taffy, root); // Whatever size and display-mode the nodes had previously, // all layouts should resolve to ZERO due to the root's DISPLAY::NONE for (node, _) in taffy.nodes.iter().filter(|(node, _)| *node != root.into()) { - if let Ok(layout) = taffy.layout(node.into()) { - assert_eq!(layout.size, Size::zero()); - assert_eq!(layout.location, Point::zero()); - } + let layout = taffy.layout(node.into()); + assert_eq!(layout.size, Size::zero()); + assert_eq!(layout.location, Point::zero()); } } } diff --git a/src/compute/taffy_tree.rs b/src/compute/taffy_tree.rs index 3cac30f7e..0bfe5c9ac 100644 --- a/src/compute/taffy_tree.rs +++ b/src/compute/taffy_tree.rs @@ -3,7 +3,7 @@ use crate::compute::{leaf, LayoutAlgorithm}; use crate::geometry::{Line, Point, Size}; use crate::style::{AvailableSpace, Display}; -use crate::tree::{Layout, LayoutTree, NodeId, RunMode, SizeBaselinesAndMargins, SizingMode, Taffy, TaffyError}; +use crate::tree::{Layout, LayoutTree, NodeId, RunMode, SizeBaselinesAndMargins, SizingMode, Taffy}; use crate::util::sys::round; #[cfg(feature = "block_layout")] @@ -34,11 +34,7 @@ fn debug_log_node( } /// Updates the stored layout of the provided `node` and its children -pub(crate) fn compute_layout( - taffy: &mut Taffy, - root: NodeId, - available_space: Size, -) -> Result<(), TaffyError> { +pub(crate) fn compute_layout(taffy: &mut Taffy, root: NodeId, available_space: Size) { // Recursively compute node layout let size_and_baselines = perform_node_layout( taffy, @@ -57,8 +53,6 @@ pub(crate) fn compute_layout( if taffy.config.use_rounding { round_layout(taffy, root, 0.0, 0.0); } - - Ok(()) } /// Perform full layout on a node. Chooses which algorithm to use based on the `display` property. diff --git a/src/style/flex.rs b/src/style/flex.rs index 8cce6d051..e6d36f219 100644 --- a/src/style/flex.rs +++ b/src/style/flex.rs @@ -87,26 +87,26 @@ mod tests { #[test] fn flex_direction_is_row() { - assert_eq!(FlexDirection::Row.is_row(), true); - assert_eq!(FlexDirection::RowReverse.is_row(), true); - assert_eq!(FlexDirection::Column.is_row(), false); - assert_eq!(FlexDirection::ColumnReverse.is_row(), false); + assert!(FlexDirection::Row.is_row()); + assert!(FlexDirection::RowReverse.is_row()); + assert!(!FlexDirection::Column.is_row()); + assert!(!FlexDirection::ColumnReverse.is_row()); } #[test] fn flex_direction_is_column() { - assert_eq!(FlexDirection::Row.is_column(), false); - assert_eq!(FlexDirection::RowReverse.is_column(), false); - assert_eq!(FlexDirection::Column.is_column(), true); - assert_eq!(FlexDirection::ColumnReverse.is_column(), true); + assert!(!FlexDirection::Row.is_column()); + assert!(!FlexDirection::RowReverse.is_column()); + assert!(FlexDirection::Column.is_column()); + assert!(FlexDirection::ColumnReverse.is_column()); } #[test] fn flex_direction_is_reverse() { - assert_eq!(FlexDirection::Row.is_reverse(), false); - assert_eq!(FlexDirection::RowReverse.is_reverse(), true); - assert_eq!(FlexDirection::Column.is_reverse(), false); - assert_eq!(FlexDirection::ColumnReverse.is_reverse(), true); + assert!(!FlexDirection::Row.is_reverse()); + assert!(FlexDirection::RowReverse.is_reverse()); + assert!(!FlexDirection::Column.is_reverse()); + assert!(FlexDirection::ColumnReverse.is_reverse()); } } } diff --git a/src/tree/taffy_tree/tree.rs b/src/tree/taffy_tree/tree.rs index a409c9e3c..7446d127c 100644 --- a/src/tree/taffy_tree/tree.rs +++ b/src/tree/taffy_tree/tree.rs @@ -173,18 +173,18 @@ impl Taffy { } /// Creates and adds a new unattached leaf node to the tree, and returns the node of the new node - pub fn new_leaf(&mut self, layout: Style) -> TaffyResult { + pub fn new_leaf(&mut self, layout: Style) -> NodeId { let id = self.nodes.insert(NodeData::new(layout)); let _ = self.children.insert(new_vec_with_capacity(0)); let _ = self.parents.insert(None); - Ok(id.into()) + id.into() } /// Creates and adds a new unattached leaf node to the tree, and returns the node of the new node /// /// Creates and adds a new leaf node with a supplied [`MeasureFunc`] - pub fn new_leaf_with_measure(&mut self, layout: Style, measure: MeasureFunc) -> TaffyResult { + pub fn new_leaf_with_measure(&mut self, layout: Style, measure: MeasureFunc) -> NodeId { let mut data = NodeData::new(layout); data.needs_measure = true; @@ -194,11 +194,11 @@ impl Taffy { let _ = self.children.insert(new_vec_with_capacity(0)); let _ = self.parents.insert(None); - Ok(id.into()) + id.into() } /// Creates and adds a new node, which may have any number of `children` - pub fn new_with_children(&mut self, layout: Style, children: &[NodeId]) -> TaffyResult { + pub fn new_with_children(&mut self, layout: Style, children: &[NodeId]) -> NodeId { let id = NodeId::from(self.nodes.insert(NodeData::new(layout))); for child in children { @@ -208,7 +208,7 @@ impl Taffy { let _ = self.children.insert(children.iter().copied().collect::<_>()); let _ = self.parents.insert(None); - Ok(id) + id } /// Drops all nodes in the tree @@ -221,7 +221,7 @@ impl Taffy { /// Remove a specific node from the tree and drop it /// /// Returns the id of the node removed. - pub fn remove(&mut self, node: NodeId) -> TaffyResult { + pub fn remove(&mut self, node: NodeId) -> NodeId { let key = node.into(); if let Some(parent) = self.parents[key] { if let Some(children) = self.children.get_mut(parent.into()) { @@ -239,11 +239,11 @@ impl Taffy { let _ = self.parents.remove(key); let _ = self.nodes.remove(key); - Ok(node) + node } /// Sets the [`MeasureFunc`] of the associated node - pub fn set_measure(&mut self, node: NodeId, measure: Option) -> TaffyResult<()> { + pub fn set_measure(&mut self, node: NodeId, measure: Option) { let key = node.into(); if let Some(measure) = measure { self.nodes[key].needs_measure = true; @@ -253,20 +253,16 @@ impl Taffy { self.measure_funcs.remove(key); } - self.mark_dirty(node)?; - - Ok(()) + self.mark_dirty(node); } /// Adds a `child` node under the supplied `parent` - pub fn add_child(&mut self, parent: NodeId, child: NodeId) -> TaffyResult<()> { + pub fn add_child(&mut self, parent: NodeId, child: NodeId) { let parent_key = parent.into(); let child_key = child.into(); self.parents[child_key] = Some(parent); self.children[parent_key].push(child); - self.mark_dirty(parent)?; - - Ok(()) + self.mark_dirty(parent); } /// Inserts a `child` node at the given `child_index` under the supplied `parent`, shifting all children after it to the right. @@ -280,13 +276,13 @@ impl Taffy { self.parents[child.into()] = Some(parent); self.children[parent_key].insert(child_index, child); - self.mark_dirty(parent)?; + self.mark_dirty(parent); Ok(()) } /// Directly sets the `children` of the supplied `parent` - pub fn set_children(&mut self, parent: NodeId, children: &[NodeId]) -> TaffyResult<()> { + pub fn set_children(&mut self, parent: NodeId, children: &[NodeId]) { let parent_key = parent.into(); // Remove node as parent from all its current children. @@ -303,9 +299,7 @@ impl Taffy { parent_children.clear(); children.iter().for_each(|child| parent_children.push(*child)); - self.mark_dirty(parent)?; - - Ok(()) + self.mark_dirty(parent); } /// Removes the `child` of the parent `node` @@ -329,7 +323,7 @@ impl Taffy { let child = self.children[parent_key].remove(child_index); self.parents[child.into()] = None; - self.mark_dirty(parent)?; + self.mark_dirty(parent); Ok(child) } @@ -354,7 +348,7 @@ impl Taffy { let old_child = core::mem::replace(&mut self.children[parent_key][child_index], new_child); self.parents[old_child.into()] = None; - self.mark_dirty(parent)?; + self.mark_dirty(parent); Ok(old_child) } @@ -371,30 +365,29 @@ impl Taffy { } /// Returns the number of children of the `parent` node - pub fn child_count(&self, parent: NodeId) -> TaffyResult { - Ok(self.children[parent.into()].len()) + pub fn child_count(&self, parent: NodeId) -> usize { + self.children[parent.into()].len() } /// Returns a list of children that belong to the parent node - pub fn children(&self, parent: NodeId) -> TaffyResult> { - Ok(self.children[parent.into()].iter().copied().collect::<_>()) + pub fn children(&self, parent: NodeId) -> Vec { + self.children[parent.into()].iter().copied().collect() } /// Sets the [`Style`] of the provided `node` - pub fn set_style(&mut self, node: NodeId, style: Style) -> TaffyResult<()> { + pub fn set_style(&mut self, node: NodeId, style: Style) { self.nodes[node.into()].style = style; - self.mark_dirty(node)?; - Ok(()) + self.mark_dirty(node); } /// Gets the [`Style`] of the provided `node` - pub fn style(&self, node: NodeId) -> TaffyResult<&Style> { - Ok(&self.nodes[node.into()].style) + pub fn style(&self, node: NodeId) -> &Style { + &self.nodes[node.into()].style } /// Return this node layout relative to its parent - pub fn layout(&self, node: NodeId) -> TaffyResult<&Layout> { - Ok(&self.nodes[node.into()].layout) + pub fn layout(&self, node: NodeId) -> &Layout { + &self.nodes[node.into()].layout } /// Marks the layout computation of this node and its children as outdated @@ -402,7 +395,7 @@ impl Taffy { /// Performs a recursive depth-first search up the tree until the root node is reached /// /// WARNING: this will stack-overflow if the tree contains a cycle - pub fn mark_dirty(&mut self, node: NodeId) -> TaffyResult<()> { + pub fn mark_dirty(&mut self, node: NodeId) { /// WARNING: this will stack-overflow if the tree contains a cycle fn mark_dirty_recursive( nodes: &mut SlotMap, @@ -417,17 +410,15 @@ impl Taffy { } mark_dirty_recursive(&mut self.nodes, &self.parents, node.into()); - - Ok(()) } /// Indicates whether the layout of this node (and its children) need to be recomputed - pub fn dirty(&self, node: NodeId) -> TaffyResult { - Ok(self.nodes[node.into()].cache.is_empty()) + pub fn dirty(&self, node: NodeId) -> bool { + self.nodes[node.into()].cache.is_empty() } /// Updates the stored layout of the provided `node` and its children - pub fn compute_layout(&mut self, node: NodeId, available_space: Size) -> TaffyResult<()> { + pub fn compute_layout(&mut self, node: NodeId, available_space: Size) { compute_layout(self, node, available_space) } } @@ -465,47 +456,41 @@ mod tests { fn test_new_leaf() { let mut taffy = Taffy::new(); - let res = taffy.new_leaf(Style::default()); - assert!(res.is_ok()); - let node = res.unwrap(); + let node = taffy.new_leaf(Style::default()); // node should be in the taffy tree and have no children - assert!(taffy.child_count(node).unwrap() == 0); + assert!(taffy.child_count(node) == 0); } #[test] fn new_leaf_with_measure() { let mut taffy = Taffy::new(); - let res = taffy.new_leaf_with_measure(Style::default(), MeasureFunc::Raw(|_, _| Size::ZERO)); - assert!(res.is_ok()); - let node = res.unwrap(); + let node = taffy.new_leaf_with_measure(Style::default(), MeasureFunc::Raw(|_, _| Size::ZERO)); // node should be in the taffy tree and have no children - assert!(taffy.child_count(node).unwrap() == 0); + assert!(taffy.child_count(node) == 0); } /// Test that new_with_children works as expected #[test] fn test_new_with_children() { let mut taffy = Taffy::new(); - let child0 = taffy.new_leaf(Style::default()).unwrap(); - let child1 = taffy.new_leaf(Style::default()).unwrap(); - let node = taffy.new_with_children(Style::default(), &[child0, child1]).unwrap(); + let child0 = taffy.new_leaf(Style::default()); + let child1 = taffy.new_leaf(Style::default()); + let node = taffy.new_with_children(Style::default(), &[child0, child1]); // node should have two children - assert_eq!(taffy.child_count(node).unwrap(), 2); - assert_eq!(taffy.children(node).unwrap()[0], child0); - assert_eq!(taffy.children(node).unwrap()[1], child1); + assert_eq!(taffy.child_count(node), 2); + assert_eq!(taffy.children(node)[0], child0); + assert_eq!(taffy.children(node)[1], child1); } #[test] fn remove_node_should_remove() { let mut taffy = Taffy::new(); - - let node = taffy.new_leaf(Style::default()).unwrap(); - - let _ = taffy.remove(node).unwrap(); + let node = taffy.new_leaf(Style::default()); + taffy.remove(node); } #[test] @@ -513,286 +498,277 @@ mod tests { let mut taffy = Taffy::new(); // Build a linear tree layout: <0> <- <1> <- <2> - let node2 = taffy.new_leaf(Style::default()).unwrap(); - let node1 = taffy.new_with_children(Style::default(), &[node2]).unwrap(); - let node0 = taffy.new_with_children(Style::default(), &[node1]).unwrap(); + let node2 = taffy.new_leaf(Style::default()); + let node1 = taffy.new_with_children(Style::default(), &[node2]); + let node0 = taffy.new_with_children(Style::default(), &[node1]); // Both node0 and node1 should have 1 child nodes - assert_eq!(taffy.children(node0).unwrap().as_slice(), &[node1]); - assert_eq!(taffy.children(node1).unwrap().as_slice(), &[node2]); + assert_eq!(taffy.children(node0).as_slice(), &[node1]); + assert_eq!(taffy.children(node1).as_slice(), &[node2]); // Disconnect the tree: <0> <2> - let _ = taffy.remove(node1).unwrap(); + taffy.remove(node1); // Both remaining nodes should have no child nodes - assert!(taffy.children(node0).unwrap().is_empty()); - assert!(taffy.children(node2).unwrap().is_empty()); + assert!(taffy.children(node0).is_empty()); + assert!(taffy.children(node2).is_empty()); } #[test] fn remove_last_node() { let mut taffy = Taffy::new(); - let parent = taffy.new_leaf(Style::default()).unwrap(); - let child = taffy.new_leaf(Style::default()).unwrap(); - taffy.add_child(parent, child).unwrap(); + let parent = taffy.new_leaf(Style::default()); + let child = taffy.new_leaf(Style::default()); + taffy.add_child(parent, child); - taffy.remove(child).unwrap(); - taffy.remove(parent).unwrap(); + taffy.remove(child); + taffy.remove(parent); } #[test] fn set_measure() { let mut taffy = Taffy::new(); let node = taffy - .new_leaf_with_measure(Style::default(), MeasureFunc::Raw(|_, _| Size { width: 200.0, height: 200.0 })) - .unwrap(); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); - assert_eq!(taffy.layout(node).unwrap().size.width, 200.0); + .new_leaf_with_measure(Style::default(), MeasureFunc::Raw(|_, _| Size { width: 200.0, height: 200.0 })); + taffy.compute_layout(node, Size::MAX_CONTENT); + assert_eq!(taffy.layout(node).size.width, 200.0); - taffy.set_measure(node, Some(MeasureFunc::Raw(|_, _| Size { width: 100.0, height: 100.0 }))).unwrap(); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); - assert_eq!(taffy.layout(node).unwrap().size.width, 100.0); + taffy.set_measure(node, Some(MeasureFunc::Raw(|_, _| Size { width: 100.0, height: 100.0 }))); + taffy.compute_layout(node, Size::MAX_CONTENT); + assert_eq!(taffy.layout(node).size.width, 100.0); } #[test] fn set_measure_of_previously_unmeasured_node() { let mut taffy = Taffy::new(); - let node = taffy.new_leaf(Style::default()).unwrap(); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); - assert_eq!(taffy.layout(node).unwrap().size.width, 0.0); + let node = taffy.new_leaf(Style::default()); + taffy.compute_layout(node, Size::MAX_CONTENT); + assert_eq!(taffy.layout(node).size.width, 0.0); - taffy.set_measure(node, Some(MeasureFunc::Raw(|_, _| Size { width: 100.0, height: 100.0 }))).unwrap(); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); - assert_eq!(taffy.layout(node).unwrap().size.width, 100.0); + taffy.set_measure(node, Some(MeasureFunc::Raw(|_, _| Size { width: 100.0, height: 100.0 }))); + taffy.compute_layout(node, Size::MAX_CONTENT); + assert_eq!(taffy.layout(node).size.width, 100.0); } /// Test that adding `add_child()` works #[test] fn add_child() { let mut taffy = Taffy::new(); - let node = taffy.new_leaf(Style::default()).unwrap(); - assert_eq!(taffy.child_count(node).unwrap(), 0); + let node = taffy.new_leaf(Style::default()); + assert_eq!(taffy.child_count(node), 0); - let child0 = taffy.new_leaf(Style::default()).unwrap(); - taffy.add_child(node, child0).unwrap(); - assert_eq!(taffy.child_count(node).unwrap(), 1); + let child0 = taffy.new_leaf(Style::default()); + taffy.add_child(node, child0); + assert_eq!(taffy.child_count(node), 1); - let child1 = taffy.new_leaf(Style::default()).unwrap(); - taffy.add_child(node, child1).unwrap(); - assert_eq!(taffy.child_count(node).unwrap(), 2); + let child1 = taffy.new_leaf(Style::default()); + taffy.add_child(node, child1); + assert_eq!(taffy.child_count(node), 2); } #[test] fn insert_child_at_index() { let mut taffy = Taffy::new(); - let child0 = taffy.new_leaf(Style::default()).unwrap(); - let child1 = taffy.new_leaf(Style::default()).unwrap(); - let child2 = taffy.new_leaf(Style::default()).unwrap(); + let child0 = taffy.new_leaf(Style::default()); + let child1 = taffy.new_leaf(Style::default()); + let child2 = taffy.new_leaf(Style::default()); - let node = taffy.new_leaf(Style::default()).unwrap(); - assert_eq!(taffy.child_count(node).unwrap(), 0); + let node = taffy.new_leaf(Style::default()); + assert_eq!(taffy.child_count(node), 0); taffy.insert_child_at_index(node, 0, child0).unwrap(); - assert_eq!(taffy.child_count(node).unwrap(), 1); - assert_eq!(taffy.children(node).unwrap()[0], child0); + assert_eq!(taffy.child_count(node), 1); + assert_eq!(taffy.children(node)[0], child0); taffy.insert_child_at_index(node, 0, child1).unwrap(); - assert_eq!(taffy.child_count(node).unwrap(), 2); - assert_eq!(taffy.children(node).unwrap()[0], child1); - assert_eq!(taffy.children(node).unwrap()[1], child0); + assert_eq!(taffy.child_count(node), 2); + assert_eq!(taffy.children(node)[0], child1); + assert_eq!(taffy.children(node)[1], child0); taffy.insert_child_at_index(node, 1, child2).unwrap(); - assert_eq!(taffy.child_count(node).unwrap(), 3); - assert_eq!(taffy.children(node).unwrap()[0], child1); - assert_eq!(taffy.children(node).unwrap()[1], child2); - assert_eq!(taffy.children(node).unwrap()[2], child0); + assert_eq!(taffy.child_count(node), 3); + assert_eq!(taffy.children(node)[0], child1); + assert_eq!(taffy.children(node)[1], child2); + assert_eq!(taffy.children(node)[2], child0); } #[test] fn set_children() { let mut taffy = Taffy::new(); - let child0 = taffy.new_leaf(Style::default()).unwrap(); - let child1 = taffy.new_leaf(Style::default()).unwrap(); - let node = taffy.new_with_children(Style::default(), &[child0, child1]).unwrap(); + let child0 = taffy.new_leaf(Style::default()); + let child1 = taffy.new_leaf(Style::default()); + let node = taffy.new_with_children(Style::default(), &[child0, child1]); - assert_eq!(taffy.child_count(node).unwrap(), 2); - assert_eq!(taffy.children(node).unwrap()[0], child0); - assert_eq!(taffy.children(node).unwrap()[1], child1); + assert_eq!(taffy.child_count(node), 2); + assert_eq!(taffy.children(node)[0], child0); + assert_eq!(taffy.children(node)[1], child1); - let child2 = taffy.new_leaf(Style::default()).unwrap(); - let child3 = taffy.new_leaf(Style::default()).unwrap(); - taffy.set_children(node, &[child2, child3]).unwrap(); + let child2 = taffy.new_leaf(Style::default()); + let child3 = taffy.new_leaf(Style::default()); + taffy.set_children(node, &[child2, child3]); - assert_eq!(taffy.child_count(node).unwrap(), 2); - assert_eq!(taffy.children(node).unwrap()[0], child2); - assert_eq!(taffy.children(node).unwrap()[1], child3); + assert_eq!(taffy.child_count(node), 2); + assert_eq!(taffy.children(node)[0], child2); + assert_eq!(taffy.children(node)[1], child3); } /// Test that removing a child works #[test] fn remove_child() { let mut taffy = Taffy::new(); - let child0 = taffy.new_leaf(Style::default()).unwrap(); - let child1 = taffy.new_leaf(Style::default()).unwrap(); - let node = taffy.new_with_children(Style::default(), &[child0, child1]).unwrap(); + let child0 = taffy.new_leaf(Style::default()); + let child1 = taffy.new_leaf(Style::default()); + let node = taffy.new_with_children(Style::default(), &[child0, child1]); - assert_eq!(taffy.child_count(node).unwrap(), 2); + assert_eq!(taffy.child_count(node), 2); taffy.remove_child(node, child0).unwrap(); - assert_eq!(taffy.child_count(node).unwrap(), 1); - assert_eq!(taffy.children(node).unwrap()[0], child1); + assert_eq!(taffy.child_count(node), 1); + assert_eq!(taffy.children(node)[0], child1); taffy.remove_child(node, child1).unwrap(); - assert_eq!(taffy.child_count(node).unwrap(), 0); + assert_eq!(taffy.child_count(node), 0); } #[test] fn remove_child_at_index() { let mut taffy = Taffy::new(); - let child0 = taffy.new_leaf(Style::default()).unwrap(); - let child1 = taffy.new_leaf(Style::default()).unwrap(); - let node = taffy.new_with_children(Style::default(), &[child0, child1]).unwrap(); + let child0 = taffy.new_leaf(Style::default()); + let child1 = taffy.new_leaf(Style::default()); + let node = taffy.new_with_children(Style::default(), &[child0, child1]); - assert_eq!(taffy.child_count(node).unwrap(), 2); + assert_eq!(taffy.child_count(node), 2); taffy.remove_child_at_index(node, 0).unwrap(); - assert_eq!(taffy.child_count(node).unwrap(), 1); - assert_eq!(taffy.children(node).unwrap()[0], child1); + assert_eq!(taffy.child_count(node), 1); + assert_eq!(taffy.children(node)[0], child1); taffy.remove_child_at_index(node, 0).unwrap(); - assert_eq!(taffy.child_count(node).unwrap(), 0); + assert_eq!(taffy.child_count(node), 0); } #[test] fn replace_child_at_index() { let mut taffy = Taffy::new(); - let child0 = taffy.new_leaf(Style::default()).unwrap(); - let child1 = taffy.new_leaf(Style::default()).unwrap(); + let child0 = taffy.new_leaf(Style::default()); + let child1 = taffy.new_leaf(Style::default()); - let node = taffy.new_with_children(Style::default(), &[child0]).unwrap(); - assert_eq!(taffy.child_count(node).unwrap(), 1); - assert_eq!(taffy.children(node).unwrap()[0], child0); + let node = taffy.new_with_children(Style::default(), &[child0]); + assert_eq!(taffy.child_count(node), 1); + assert_eq!(taffy.children(node)[0], child0); taffy.replace_child_at_index(node, 0, child1).unwrap(); - assert_eq!(taffy.child_count(node).unwrap(), 1); - assert_eq!(taffy.children(node).unwrap()[0], child1); + assert_eq!(taffy.child_count(node), 1); + assert_eq!(taffy.children(node)[0], child1); } #[test] fn test_child_at_index() { let mut taffy = Taffy::new(); - let child0 = taffy.new_leaf(Style::default()).unwrap(); - let child1 = taffy.new_leaf(Style::default()).unwrap(); - let child2 = taffy.new_leaf(Style::default()).unwrap(); - let node = taffy.new_with_children(Style::default(), &[child0, child1, child2]).unwrap(); + let child0 = taffy.new_leaf(Style::default()); + let child1 = taffy.new_leaf(Style::default()); + let child2 = taffy.new_leaf(Style::default()); + let node = taffy.new_with_children(Style::default(), &[child0, child1, child2]); - assert!(if let Ok(result) = taffy.child_at_index(node, 0) { result == child0 } else { false }); - assert!(if let Ok(result) = taffy.child_at_index(node, 1) { result == child1 } else { false }); - assert!(if let Ok(result) = taffy.child_at_index(node, 2) { result == child2 } else { false }); + assert_eq!(taffy.child_at_index(node, 0).unwrap(), child0); + assert_eq!(taffy.child_at_index(node, 1).unwrap(), child1); + assert_eq!(taffy.child_at_index(node, 2).unwrap(), child2); } #[test] fn test_child_count() { let mut taffy = Taffy::new(); - let child0 = taffy.new_leaf(Style::default()).unwrap(); - let child1 = taffy.new_leaf(Style::default()).unwrap(); - let node = taffy.new_with_children(Style::default(), &[child0, child1]).unwrap(); + let child0 = taffy.new_leaf(Style::default()); + let child1 = taffy.new_leaf(Style::default()); + let node = taffy.new_with_children(Style::default(), &[child0, child1]); - assert!(if let Ok(count) = taffy.child_count(node) { count == 2 } else { false }); - assert!(if let Ok(count) = taffy.child_count(child0) { count == 0 } else { false }); - assert!(if let Ok(count) = taffy.child_count(child1) { count == 0 } else { false }); + assert_eq!(taffy.child_count(node), 2); + assert_eq!(taffy.child_count(child0), 0); + assert_eq!(taffy.child_count(child1), 0); } #[allow(clippy::vec_init_then_push)] #[test] fn test_children() { let mut taffy = Taffy::new(); - let child0 = taffy.new_leaf(Style::default()).unwrap(); - let child1 = taffy.new_leaf(Style::default()).unwrap(); - let node = taffy.new_with_children(Style::default(), &[child0, child1]).unwrap(); + let child0 = taffy.new_leaf(Style::default()); + let child1 = taffy.new_leaf(Style::default()); + let node = taffy.new_with_children(Style::default(), &[child0, child1]); let mut children = sys::Vec::new(); children.push(child0); children.push(child1); - let children_result = taffy.children(node).unwrap(); + let children_result = taffy.children(node); assert_eq!(children_result, children); - assert!(taffy.children(child0).unwrap().is_empty()); + assert!(taffy.children(child0).is_empty()); } #[test] fn test_set_style() { let mut taffy = Taffy::new(); - let node = taffy.new_leaf(Style::default()).unwrap(); - assert_eq!(taffy.style(node).unwrap().display, Display::Flex); + let node = taffy.new_leaf(Style::default()); + assert_eq!(taffy.style(node).display, Display::Flex); - taffy.set_style(node, Style { display: Display::None, ..Style::default() }).unwrap(); - assert_eq!(taffy.style(node).unwrap().display, Display::None); + taffy.set_style(node, Style { display: Display::None, ..Style::default() }); + assert_eq!(taffy.style(node).display, Display::None); } #[test] fn test_style() { let mut taffy = Taffy::new(); let style = Style { display: Display::None, flex_direction: FlexDirection::RowReverse, ..Default::default() }; - - let node = taffy.new_leaf(style.clone()).unwrap(); - - let res = taffy.style(node); - assert!(res.is_ok()); - assert!(res.unwrap() == &style); + let node = taffy.new_leaf(style.clone()); + assert!(taffy.style(node) == &style); } #[test] fn test_layout() { let mut taffy = Taffy::new(); - let node = taffy.new_leaf(Style::default()).unwrap(); - + let node = taffy.new_leaf(Style::default()); // TODO: Improve this test? - let res = taffy.layout(node); - assert!(res.is_ok()); + taffy.layout(node); } #[test] fn test_mark_dirty() { let mut taffy = Taffy::new(); - let child0 = taffy.new_leaf(Style::default()).unwrap(); - let child1 = taffy.new_leaf(Style::default()).unwrap(); - let node = taffy.new_with_children(Style::default(), &[child0, child1]).unwrap(); + let child0 = taffy.new_leaf(Style::default()); + let child1 = taffy.new_leaf(Style::default()); + let node = taffy.new_with_children(Style::default(), &[child0, child1]); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); + taffy.compute_layout(node, Size::MAX_CONTENT); - assert_eq!(taffy.dirty(child0).unwrap(), false); - assert_eq!(taffy.dirty(child1).unwrap(), false); - assert_eq!(taffy.dirty(node).unwrap(), false); + assert_eq!(taffy.dirty(child0), false); + assert_eq!(taffy.dirty(child1), false); + assert_eq!(taffy.dirty(node), false); - taffy.mark_dirty(node).unwrap(); - assert_eq!(taffy.dirty(child0).unwrap(), false); - assert_eq!(taffy.dirty(child1).unwrap(), false); - assert_eq!(taffy.dirty(node).unwrap(), true); + taffy.mark_dirty(node); + assert_eq!(taffy.dirty(child0), false); + assert_eq!(taffy.dirty(child1), false); + assert_eq!(taffy.dirty(node), true); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); - taffy.mark_dirty(child0).unwrap(); - assert_eq!(taffy.dirty(child0).unwrap(), true); - assert_eq!(taffy.dirty(child1).unwrap(), false); - assert_eq!(taffy.dirty(node).unwrap(), true); + taffy.compute_layout(node, Size::MAX_CONTENT); + taffy.mark_dirty(child0); + assert_eq!(taffy.dirty(child0), true); + assert_eq!(taffy.dirty(child1), false); + assert_eq!(taffy.dirty(node), true); } #[test] fn compute_layout_should_produce_valid_result() { let mut taffy = Taffy::new(); - let node_result = taffy.new_leaf(Style { + let node = taffy.new_leaf(Style { size: Size { width: Dimension::Length(10f32), height: Dimension::Length(10f32) }, ..Default::default() }); - assert!(node_result.is_ok()); - let node = node_result.unwrap(); - let layout_result = taffy.compute_layout( + // TODO: improve test by asserting equalities + taffy.compute_layout( node, Size { width: AvailableSpace::Definite(100.), height: AvailableSpace::Definite(100.) }, ); - assert!(layout_result.is_ok()); } #[test] @@ -801,30 +777,21 @@ mod tests { let mut taffy = Taffy::new(); - let node = taffy - .new_leaf(Style { - size: Size { width: Dimension::Percent(1f32), height: Dimension::Percent(1f32) }, + let node = taffy.new_leaf(Style { + size: Size { width: Dimension::Percent(1f32), height: Dimension::Percent(1f32) }, + ..Default::default() + }); + + let root = taffy.new_with_children( + Style { + size: Size { width: Dimension::Length(100f32), height: Dimension::Length(100f32) }, + padding: Rect { left: length(10f32), right: length(20f32), top: length(30f32), bottom: length(40f32) }, ..Default::default() - }) - .unwrap(); - - let root = taffy - .new_with_children( - Style { - size: Size { width: Dimension::Length(100f32), height: Dimension::Length(100f32) }, - padding: Rect { - left: length(10f32), - right: length(20f32), - top: length(30f32), - bottom: length(40f32), - }, - ..Default::default() - }, - &[node], - ) - .unwrap(); - - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); + }, + &[node], + ); + + taffy.compute_layout(root, Size::MAX_CONTENT); // If Layout::location represents top-left coord, 'node' location // must be (due applied 'root' padding): {x: 10, y: 30}. @@ -834,7 +801,7 @@ mod tests { // - bottom-left: {x: 10, y: 40} // - top-right: {x: 20, y: 30} // - bottom-right: {x: 20, y: 40} - let layout = taffy.layout(node).unwrap(); + let layout = taffy.layout(node); assert_eq!(layout.location.x, 10f32); assert_eq!(layout.location.y, 30f32); } diff --git a/tests/border_and_padding.rs b/tests/border_and_padding.rs index a587ce7e2..a9a2b6871 100644 --- a/tests/border_and_padding.rs +++ b/tests/border_and_padding.rs @@ -10,25 +10,21 @@ fn arr_to_rect(items: [T; 4]) -> Rect { fn border_on_a_single_axis_doesnt_increase_size() { for i in 0..4 { let mut taffy = Taffy::new(); - let node = taffy - .new_leaf(Style { - border: { - let mut lengths = [LengthPercentage::ZERO; 4]; - lengths[i] = LengthPercentage::Length(10.); - arr_to_rect(lengths) - }, - ..Default::default() - }) - .unwrap(); + let node = taffy.new_leaf(Style { + border: { + let mut lengths = [LengthPercentage::ZERO; 4]; + lengths[i] = LengthPercentage::Length(10.); + arr_to_rect(lengths) + }, + ..Default::default() + }); - taffy - .compute_layout( - node, - Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(100.0) }, - ) - .unwrap(); + taffy.compute_layout( + node, + Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(100.0) }, + ); - let layout = taffy.layout(node).unwrap(); + let layout = taffy.layout(node); assert_eq!(layout.size.width * layout.size.height, 0.); } } @@ -38,25 +34,21 @@ fn border_on_a_single_axis_doesnt_increase_size() { fn padding_on_a_single_axis_doesnt_increase_size() { for i in 0..4 { let mut taffy = Taffy::new(); - let node = taffy - .new_leaf(Style { - padding: { - let mut lengths = [LengthPercentage::ZERO; 4]; - lengths[i] = LengthPercentage::Length(10.); - arr_to_rect(lengths) - }, - ..Default::default() - }) - .unwrap(); + let node = taffy.new_leaf(Style { + padding: { + let mut lengths = [LengthPercentage::ZERO; 4]; + lengths[i] = LengthPercentage::Length(10.); + arr_to_rect(lengths) + }, + ..Default::default() + }); - taffy - .compute_layout( - node, - Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(100.0) }, - ) - .unwrap(); + taffy.compute_layout( + node, + Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(100.0) }, + ); - let layout = taffy.layout(node).unwrap(); + let layout = taffy.layout(node); assert_eq!(layout.size.width * layout.size.height, 0.); } } @@ -71,15 +63,13 @@ fn border_and_padding_on_a_single_axis_doesnt_increase_size() { lengths[i] = LengthPercentage::Length(10.); arr_to_rect(lengths) }; - let node = taffy.new_leaf(Style { border: rect, padding: rect, ..Default::default() }).unwrap(); + let node = taffy.new_leaf(Style { border: rect, padding: rect, ..Default::default() }); - taffy - .compute_layout( - node, - Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(100.0) }, - ) - .unwrap(); - let layout = taffy.layout(node).unwrap(); + taffy.compute_layout( + node, + Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(100.0) }, + ); + let layout = taffy.layout(node); assert_eq!(layout.size.width * layout.size.height, 0.); } } @@ -89,18 +79,15 @@ fn border_and_padding_on_a_single_axis_doesnt_increase_size() { fn vertical_border_and_padding_percentage_values_use_available_space_correctly() { let mut taffy = Taffy::new(); - let node = taffy - .new_leaf(Style { - padding: Rect { left: LengthPercentage::Percent(1.0), top: LengthPercentage::Percent(1.0), ..Rect::zero() }, - ..Default::default() - }) - .unwrap(); + let node = taffy.new_leaf(Style { + padding: Rect { left: LengthPercentage::Percent(1.0), top: LengthPercentage::Percent(1.0), ..Rect::zero() }, + ..Default::default() + }); taffy - .compute_layout(node, Size { width: AvailableSpace::Definite(200.0), height: AvailableSpace::Definite(100.0) }) - .unwrap(); + .compute_layout(node, Size { width: AvailableSpace::Definite(200.0), height: AvailableSpace::Definite(100.0) }); - let layout = taffy.layout(node).unwrap(); + let layout = taffy.layout(node); assert_eq!(layout.size.width, 200.0); assert_eq!(layout.size.height, 200.0); } diff --git a/tests/caching.rs b/tests/caching.rs index 0ef57c36b..1ddade36a 100644 --- a/tests/caching.rs +++ b/tests/caching.rs @@ -10,25 +10,20 @@ mod caching { let mut taffy = Taffy::new(); static NUM_MEASURES: AtomicU32 = AtomicU32::new(0); - let leaf = taffy - .new_leaf_with_measure( - Style::default(), - MeasureFunc::Raw(|known_dimensions, _available_space| { - NUM_MEASURES.fetch_add(1, Ordering::SeqCst); - Size { - width: known_dimensions.width.unwrap_or(50.0), - height: known_dimensions.height.unwrap_or(50.0), - } - }), - ) - .unwrap(); - - let mut node = taffy.new_with_children(Style::DEFAULT, &[leaf]).unwrap(); + let leaf = taffy.new_leaf_with_measure( + Style::default(), + MeasureFunc::Raw(|known_dimensions, _available_space| { + NUM_MEASURES.fetch_add(1, Ordering::SeqCst); + Size { width: known_dimensions.width.unwrap_or(50.0), height: known_dimensions.height.unwrap_or(50.0) } + }), + ); + + let mut node = taffy.new_with_children(Style::DEFAULT, &[leaf]); for _ in 0..100 { - node = taffy.new_with_children(Style::DEFAULT, &[node]).unwrap(); + node = taffy.new_with_children(Style::DEFAULT, &[node]); } - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); + taffy.compute_layout(node, Size::MAX_CONTENT); assert_eq!(NUM_MEASURES.load(Ordering::SeqCst), 3); } @@ -43,25 +38,20 @@ mod caching { let mut taffy = Taffy::new(); static NUM_MEASURES: AtomicU32 = AtomicU32::new(0); - let leaf = taffy - .new_leaf_with_measure( - style(), - MeasureFunc::Raw(|known_dimensions, _available_space| { - NUM_MEASURES.fetch_add(1, Ordering::SeqCst); - Size { - width: known_dimensions.width.unwrap_or(50.0), - height: known_dimensions.height.unwrap_or(50.0), - } - }), - ) - .unwrap(); + let leaf = taffy.new_leaf_with_measure( + style(), + MeasureFunc::Raw(|known_dimensions, _available_space| { + NUM_MEASURES.fetch_add(1, Ordering::SeqCst); + Size { width: known_dimensions.width.unwrap_or(50.0), height: known_dimensions.height.unwrap_or(50.0) } + }), + ); - let mut node = taffy.new_with_children(Style::DEFAULT, &[leaf]).unwrap(); + let mut node = taffy.new_with_children(Style::DEFAULT, &[leaf]); for _ in 0..100 { - node = taffy.new_with_children(Style::DEFAULT, &[node]).unwrap(); + node = taffy.new_with_children(Style::DEFAULT, &[node]); } - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); + taffy.compute_layout(node, Size::MAX_CONTENT); assert_eq!(NUM_MEASURES.load(Ordering::SeqCst), 3); } } diff --git a/tests/generated/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs b/tests/generated/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs index 979f1891d..d926c325b 100644 --- a/tests/generated/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs +++ b/tests/generated/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs @@ -3,42 +3,38 @@ fn absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: taffy::style::LengthPercentageAuto::Percent(0.05f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node0, 360f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); diff --git a/tests/generated/absolute_aspect_ratio_fill_height.rs b/tests/generated/absolute_aspect_ratio_fill_height.rs index dc1484041..d7a8281e4 100644 --- a/tests/generated/absolute_aspect_ratio_fill_height.rs +++ b/tests/generated/absolute_aspect_ratio_fill_height.rs @@ -3,43 +3,39 @@ fn absolute_aspect_ratio_fill_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); diff --git a/tests/generated/absolute_aspect_ratio_fill_height_from_inset.rs b/tests/generated/absolute_aspect_ratio_fill_height_from_inset.rs index b9dadd3d3..44f95f12f 100644 --- a/tests/generated/absolute_aspect_ratio_fill_height_from_inset.rs +++ b/tests/generated/absolute_aspect_ratio_fill_height_from_inset.rs @@ -3,42 +3,38 @@ fn absolute_aspect_ratio_fill_height_from_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.1f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0, 107f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); diff --git a/tests/generated/absolute_aspect_ratio_fill_max_height.rs b/tests/generated/absolute_aspect_ratio_fill_max_height.rs index 77a233bdd..2a74fd03a 100644 --- a/tests/generated/absolute_aspect_ratio_fill_max_height.rs +++ b/tests/generated/absolute_aspect_ratio_fill_max_height.rs @@ -3,30 +3,46 @@ fn absolute_aspect_ratio_fill_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { position : taffy :: style :: Position :: Absolute , max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Length (50f32) , height : auto () , } , aspect_ratio : Some (3f32) , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (3f32)) }) ,) . unwrap () ; - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + position: taffy::style::Position::Absolute, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + aspect_ratio: Some(3f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = + "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(3f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0, 17f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/absolute_aspect_ratio_fill_max_width.rs b/tests/generated/absolute_aspect_ratio_fill_max_width.rs index 16600b4c1..59b2bf523 100644 --- a/tests/generated/absolute_aspect_ratio_fill_max_width.rs +++ b/tests/generated/absolute_aspect_ratio_fill_max_width.rs @@ -3,30 +3,46 @@ fn absolute_aspect_ratio_fill_max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { position : taffy :: style :: Position :: Absolute , max_size : taffy :: geometry :: Size { width : auto () , height : taffy :: style :: Dimension :: Length (50f32) , } , aspect_ratio : Some (0.5f32) , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (0.5f32)) }) ,) . unwrap () ; - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + position: taffy::style::Position::Absolute, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + aspect_ratio: Some(0.5f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = + "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(0.5f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node0, 25f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/absolute_aspect_ratio_fill_min_height.rs b/tests/generated/absolute_aspect_ratio_fill_min_height.rs index 99c744c8e..979cfd30a 100644 --- a/tests/generated/absolute_aspect_ratio_fill_min_height.rs +++ b/tests/generated/absolute_aspect_ratio_fill_min_height.rs @@ -3,37 +3,33 @@ fn absolute_aspect_ratio_fill_min_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - aspect_ratio: Some(3f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + aspect_ratio: Some(3f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0, 17f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/absolute_aspect_ratio_fill_min_width.rs b/tests/generated/absolute_aspect_ratio_fill_min_width.rs index 09c215184..da2bc3e9c 100644 --- a/tests/generated/absolute_aspect_ratio_fill_min_width.rs +++ b/tests/generated/absolute_aspect_ratio_fill_min_width.rs @@ -3,37 +3,33 @@ fn absolute_aspect_ratio_fill_min_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - aspect_ratio: Some(0.5f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + aspect_ratio: Some(0.5f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node0, 25f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/absolute_aspect_ratio_fill_width.rs b/tests/generated/absolute_aspect_ratio_fill_width.rs index a23b9fd14..044de25e1 100644 --- a/tests/generated/absolute_aspect_ratio_fill_width.rs +++ b/tests/generated/absolute_aspect_ratio_fill_width.rs @@ -3,43 +3,39 @@ fn absolute_aspect_ratio_fill_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) }, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); diff --git a/tests/generated/absolute_aspect_ratio_fill_width_from_inset.rs b/tests/generated/absolute_aspect_ratio_fill_width_from_inset.rs index e1acc42f2..2d2337354 100644 --- a/tests/generated/absolute_aspect_ratio_fill_width_from_inset.rs +++ b/tests/generated/absolute_aspect_ratio_fill_width_from_inset.rs @@ -3,42 +3,38 @@ fn absolute_aspect_ratio_fill_width_from_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.3f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.3f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/absolute_aspect_ratio_height_overrides_inset.rs b/tests/generated/absolute_aspect_ratio_height_overrides_inset.rs index 3a161c7f5..eece058a8 100644 --- a/tests/generated/absolute_aspect_ratio_height_overrides_inset.rs +++ b/tests/generated/absolute_aspect_ratio_height_overrides_inset.rs @@ -3,43 +3,39 @@ fn absolute_aspect_ratio_height_overrides_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.1f32) }, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.3f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.1f32) }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.3f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node0, 90f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/absolute_aspect_ratio_width_overrides_inset.rs b/tests/generated/absolute_aspect_ratio_width_overrides_inset.rs index a37862f7c..75c2f9cc1 100644 --- a/tests/generated/absolute_aspect_ratio_width_overrides_inset.rs +++ b/tests/generated/absolute_aspect_ratio_width_overrides_inset.rs @@ -3,43 +3,39 @@ fn absolute_aspect_ratio_width_overrides_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.4f32), height: auto() }, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.1f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.4f32), height: auto() }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); assert_eq!(size.height, 53f32, "height of node {:?}. Expected {}. Actual {}", node0, 53f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); diff --git a/tests/generated/absolute_child_with_cross_margin.rs b/tests/generated/absolute_child_with_cross_margin.rs index e2e5129c0..4320d7716 100644 --- a/tests/generated/absolute_child_with_cross_margin.rs +++ b/tests/generated/absolute_child_with_cross_margin.rs @@ -3,94 +3,80 @@ fn absolute_child_with_cross_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(28f32), + height: taffy::style::Dimension::Length(27f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { + position: taffy::style::Position::Absolute, align_content: Some(taffy::style::AlignContent::Stretch), + flex_grow: 0f32, + flex_shrink: 1f32, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(28f32), - height: taffy::style::Dimension::Length(27f32), + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Length(15f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(4f32), + bottom: zero(), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { - position: taffy::style::Position::Absolute, - align_content: Some(taffy::style::AlignContent::Stretch), - flex_grow: 0f32, - flex_shrink: 1f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Length(15f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(4f32), - bottom: zero(), - }, - ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "\n "; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(27f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(311f32), + height: taffy::style::Dimension::Length(0f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "\n "; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(27f32), + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(311f32), + height: taffy::style::Dimension::Length(36893500000000000000f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::SpaceBetween), - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(311f32), - height: taffy::style::Dimension::Length(0f32), - }, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(311f32), - height: taffy::style::Dimension::Length(36893500000000000000f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 311f32, "width of node {:?}. Expected {}. Actual {}", node, 311f32, size.width); assert_eq!(size.height, 27f32, "height of node {:?}. Expected {}. Actual {}", node, 27f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node0, 28f32, size.width); assert_eq!(size.height, 27f32, "height of node {:?}. Expected {}. Actual {}", node0, 27f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 311f32, "width of node {:?}. Expected {}. Actual {}", node1, 311f32, size.width); assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node1, 15f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 4f32, "y of node {:?}. Expected {}. Actual {}", node1, 4f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node2, 25f32, size.width); assert_eq!(size.height, 27f32, "height of node {:?}. Expected {}. Actual {}", node2, 27f32, size.height); assert_eq!(location.x, 286f32, "x of node {:?}. Expected {}. Actual {}", node2, 286f32, location.x); diff --git a/tests/generated/absolute_child_with_main_margin.rs b/tests/generated/absolute_child_with_main_margin.rs index 406f7bf11..d0db6151e 100644 --- a/tests/generated/absolute_child_with_main_margin.rs +++ b/tests/generated/absolute_child_with_main_margin.rs @@ -3,44 +3,40 @@ fn absolute_child_with_main_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(9f32), + height: taffy::style::Dimension::Length(9f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(7f32), + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(9f32), - height: taffy::style::Dimension::Length(9f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(7f32), - right: zero(), - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(37f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(37f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 37f32, "height of node {:?}. Expected {}. Actual {}", node, 37f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node0, 9f32, size.width); assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node0, 9f32, size.height); assert_eq!(location.x, 7f32, "x of node {:?}. Expected {}. Actual {}", node0, 7f32, location.x); diff --git a/tests/generated/absolute_child_with_max_height.rs b/tests/generated/absolute_child_with_max_height.rs index e0faf49ae..693453712 100644 --- a/tests/generated/absolute_child_with_max_height.rs +++ b/tests/generated/absolute_child_with_max_height.rs @@ -3,60 +3,54 @@ fn absolute_child_with_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + position: taffy::style::Position::Absolute, + flex_direction: taffy::style::FlexDirection::Column, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(20f32), + }, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - position: taffy::style::Position::Absolute, - flex_direction: taffy::style::FlexDirection::Column, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(20f32), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node0, 150f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node00, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/absolute_child_with_max_height_larger_shrinkable_grandchild.rs b/tests/generated/absolute_child_with_max_height_larger_shrinkable_grandchild.rs index cbb04af7e..d5c4f5f73 100644 --- a/tests/generated/absolute_child_with_max_height_larger_shrinkable_grandchild.rs +++ b/tests/generated/absolute_child_with_max_height_larger_shrinkable_grandchild.rs @@ -3,59 +3,53 @@ fn absolute_child_with_max_height_larger_shrinkable_grandchild() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Length(150f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - position: taffy::style::Position::Absolute, - flex_direction: taffy::style::FlexDirection::Column, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(20f32), - }, - ..Default::default() + let node00 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Length(150f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + position: taffy::style::Position::Absolute, + flex_direction: taffy::style::FlexDirection::Column, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(20f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center.rs index fa6cafcce..9ef7d8877 100644 --- a/tests/generated/absolute_layout_align_items_and_justify_content_center.rs +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center.rs @@ -3,40 +3,36 @@ fn absolute_layout_align_items_and_justify_content_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), + width: taffy::style::Dimension::Length(110f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(110f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs index 405e329fb..cfd014a65 100644 --- a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs @@ -3,46 +3,42 @@ fn absolute_layout_align_items_and_justify_content_center_and_bottom_position() #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + width: taffy::style::Dimension::Length(110f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(110f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs index 7a97d3fe3..c132559ae 100644 --- a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs @@ -3,46 +3,42 @@ fn absolute_layout_align_items_and_justify_content_center_and_left_position() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: auto(), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: auto(), - top: auto(), - bottom: auto(), + width: taffy::style::Dimension::Length(110f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(110f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs index ae9164b75..f26fbb969 100644 --- a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs @@ -3,46 +3,42 @@ fn absolute_layout_align_items_and_justify_content_center_and_right_position() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: auto(), - bottom: auto(), + width: taffy::style::Dimension::Length(110f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(110f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node0, 45f32, location.x); diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs index 75e504fd9..6f481544d 100644 --- a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs @@ -3,46 +3,42 @@ fn absolute_layout_align_items_and_justify_content_center_and_top_position() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: auto(), + width: taffy::style::Dimension::Length(110f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(110f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_flex_end.rs b/tests/generated/absolute_layout_align_items_and_justify_content_flex_end.rs index 4394e23e5..abaec69ef 100644 --- a/tests/generated/absolute_layout_align_items_and_justify_content_flex_end.rs +++ b/tests/generated/absolute_layout_align_items_and_justify_content_flex_end.rs @@ -3,40 +3,36 @@ fn absolute_layout_align_items_and_justify_content_flex_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::FlexEnd), + justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), + width: taffy::style::Dimension::Length(110f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::FlexEnd), - justify_content: Some(taffy::style::JustifyContent::FlexEnd), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(110f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); diff --git a/tests/generated/absolute_layout_align_items_center.rs b/tests/generated/absolute_layout_align_items_center.rs index 3528b5719..96a1780b1 100644 --- a/tests/generated/absolute_layout_align_items_center.rs +++ b/tests/generated/absolute_layout_align_items_center.rs @@ -3,39 +3,35 @@ fn absolute_layout_align_items_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), + width: taffy::style::Dimension::Length(110f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(110f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/absolute_layout_align_items_center_on_child_only.rs b/tests/generated/absolute_layout_align_items_center_on_child_only.rs index 078cd2477..87f0a05f8 100644 --- a/tests/generated/absolute_layout_align_items_center_on_child_only.rs +++ b/tests/generated/absolute_layout_align_items_center_on_child_only.rs @@ -3,39 +3,35 @@ fn absolute_layout_align_items_center_on_child_only() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::Center), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), + width: taffy::style::Dimension::Length(110f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(110f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/absolute_layout_child_order.rs b/tests/generated/absolute_layout_child_order.rs index 002bba63c..4909ec3df 100644 --- a/tests/generated/absolute_layout_child_order.rs +++ b/tests/generated/absolute_layout_child_order.rs @@ -3,68 +3,60 @@ fn absolute_layout_child_order() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), + width: taffy::style::Dimension::Length(110f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(110f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node0, 55f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node1, 25f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node2, 55f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 55f32, "x of node {:?}. Expected {}. Actual {}", node2, 55f32, location.x); diff --git a/tests/generated/absolute_layout_in_wrap_reverse_column_container.rs b/tests/generated/absolute_layout_in_wrap_reverse_column_container.rs index 2dc77dbc2..2d877f4ab 100644 --- a/tests/generated/absolute_layout_in_wrap_reverse_column_container.rs +++ b/tests/generated/absolute_layout_in_wrap_reverse_column_container.rs @@ -3,40 +3,36 @@ fn absolute_layout_in_wrap_reverse_column_container() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::WrapReverse, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::WrapReverse, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); diff --git a/tests/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs b/tests/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs index 3b5289149..4eb239cfa 100644 --- a/tests/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs +++ b/tests/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs @@ -3,41 +3,37 @@ fn absolute_layout_in_wrap_reverse_column_container_flex_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::FlexEnd), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::FlexEnd), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::WrapReverse, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::WrapReverse, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/absolute_layout_in_wrap_reverse_row_container.rs b/tests/generated/absolute_layout_in_wrap_reverse_row_container.rs index dda7e62b2..4f53ab0a1 100644 --- a/tests/generated/absolute_layout_in_wrap_reverse_row_container.rs +++ b/tests/generated/absolute_layout_in_wrap_reverse_row_container.rs @@ -3,39 +3,35 @@ fn absolute_layout_in_wrap_reverse_row_container() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::WrapReverse, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::WrapReverse, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs b/tests/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs index 919860620..cfe2e3752 100644 --- a/tests/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs +++ b/tests/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs @@ -3,40 +3,36 @@ fn absolute_layout_in_wrap_reverse_row_container_flex_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::FlexEnd), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::FlexEnd), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::WrapReverse, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::WrapReverse, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/absolute_layout_justify_content_center.rs b/tests/generated/absolute_layout_justify_content_center.rs index 5457421ad..ddc9958a2 100644 --- a/tests/generated/absolute_layout_justify_content_center.rs +++ b/tests/generated/absolute_layout_justify_content_center.rs @@ -3,39 +3,35 @@ fn absolute_layout_justify_content_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), + width: taffy::style::Dimension::Length(110f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(110f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); diff --git a/tests/generated/absolute_layout_no_size.rs b/tests/generated/absolute_layout_no_size.rs index 11bddf745..a625d97c3 100644 --- a/tests/generated/absolute_layout_no_size.rs +++ b/tests/generated/absolute_layout_no_size.rs @@ -3,31 +3,28 @@ fn absolute_layout_no_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = + taffy.new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs b/tests/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs index 86edace6d..8c4efa86c 100644 --- a/tests/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs +++ b/tests/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs @@ -3,83 +3,75 @@ fn absolute_layout_percentage_bottom_based_on_parent_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.5f32), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.5f32), - bottom: auto(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node1, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node2, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/absolute_layout_percentage_height.rs b/tests/generated/absolute_layout_percentage_height.rs index 642bde4e6..ad4db12d3 100644 --- a/tests/generated/absolute_layout_percentage_height.rs +++ b/tests/generated/absolute_layout_percentage_height.rs @@ -3,44 +3,40 @@ fn absolute_layout_percentage_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Percent(0.5f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Percent(0.5f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: auto(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/absolute_layout_row_width_height_end_bottom.rs b/tests/generated/absolute_layout_row_width_height_end_bottom.rs index 2ec9644ff..db51c4292 100644 --- a/tests/generated/absolute_layout_row_width_height_end_bottom.rs +++ b/tests/generated/absolute_layout_row_width_height_end_bottom.rs @@ -3,44 +3,40 @@ fn absolute_layout_row_width_height_end_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); diff --git a/tests/generated/absolute_layout_start_top_end_bottom.rs b/tests/generated/absolute_layout_start_top_end_bottom.rs index 78baeeb19..e5846ea7a 100644 --- a/tests/generated/absolute_layout_start_top_end_bottom.rs +++ b/tests/generated/absolute_layout_start_top_end_bottom.rs @@ -3,40 +3,36 @@ fn absolute_layout_start_top_end_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/absolute_layout_width_height_end_bottom.rs b/tests/generated/absolute_layout_width_height_end_bottom.rs index b220f4716..e18b2521e 100644 --- a/tests/generated/absolute_layout_width_height_end_bottom.rs +++ b/tests/generated/absolute_layout_width_height_end_bottom.rs @@ -3,44 +3,40 @@ fn absolute_layout_width_height_end_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); diff --git a/tests/generated/absolute_layout_width_height_start_top.rs b/tests/generated/absolute_layout_width_height_start_top.rs index 3e6e0bf2a..29e37d183 100644 --- a/tests/generated/absolute_layout_width_height_start_top.rs +++ b/tests/generated/absolute_layout_width_height_start_top.rs @@ -3,44 +3,40 @@ fn absolute_layout_width_height_start_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: auto(), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/absolute_layout_width_height_start_top_end_bottom.rs b/tests/generated/absolute_layout_width_height_start_top_end_bottom.rs index 104639876..ed0bb2758 100644 --- a/tests/generated/absolute_layout_width_height_start_top_end_bottom.rs +++ b/tests/generated/absolute_layout_width_height_start_top_end_bottom.rs @@ -3,44 +3,40 @@ fn absolute_layout_width_height_start_top_end_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/absolute_layout_within_border.rs b/tests/generated/absolute_layout_within_border.rs index c1d50b1c4..6c7e2d2b9 100644 --- a/tests/generated/absolute_layout_within_border.rs +++ b/tests/generated/absolute_layout_within_border.rs @@ -3,131 +3,121 @@ fn absolute_layout_within_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: auto(), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: auto(), + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: auto(), + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); diff --git a/tests/generated/absolute_margin_bottom_left.rs b/tests/generated/absolute_margin_bottom_left.rs index e791ce6d6..6fca61110 100644 --- a/tests/generated/absolute_margin_bottom_left.rs +++ b/tests/generated/absolute_margin_bottom_left.rs @@ -3,46 +3,42 @@ fn absolute_margin_bottom_left() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - justify_content: Some(taffy::style::JustifyContent::FlexEnd), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/absolute_minmax_bottom_right_max.rs b/tests/generated/absolute_minmax_bottom_right_max.rs index 6827c06cc..d5b2ec5ad 100644 --- a/tests/generated/absolute_minmax_bottom_right_max.rs +++ b/tests/generated/absolute_minmax_bottom_right_max.rs @@ -3,48 +3,44 @@ fn absolute_minmax_bottom_right_max() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(30f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: taffy::style::Dimension::Length(100f32), }, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(30f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); diff --git a/tests/generated/absolute_minmax_bottom_right_min_max.rs b/tests/generated/absolute_minmax_bottom_right_min_max.rs index c9c8d6cc7..b96ccef43 100644 --- a/tests/generated/absolute_minmax_bottom_right_min_max.rs +++ b/tests/generated/absolute_minmax_bottom_right_min_max.rs @@ -3,48 +3,44 @@ fn absolute_minmax_bottom_right_min_max() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), - }, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(30f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(30f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); diff --git a/tests/generated/absolute_minmax_bottom_right_min_max_preferred.rs b/tests/generated/absolute_minmax_bottom_right_min_max_preferred.rs index 769eb9190..5cdc3cdde 100644 --- a/tests/generated/absolute_minmax_bottom_right_min_max_preferred.rs +++ b/tests/generated/absolute_minmax_bottom_right_min_max_preferred.rs @@ -3,52 +3,48 @@ fn absolute_minmax_bottom_right_min_max_preferred() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), + }, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(30f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), - }, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(30f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); diff --git a/tests/generated/absolute_minmax_top_left_bottom_right_max.rs b/tests/generated/absolute_minmax_top_left_bottom_right_max.rs index 4f84b1cf1..51ef29b59 100644 --- a/tests/generated/absolute_minmax_top_left_bottom_right_max.rs +++ b/tests/generated/absolute_minmax_top_left_bottom_right_max.rs @@ -3,44 +3,40 @@ fn absolute_minmax_top_left_bottom_right_max() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(30f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(30f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/absolute_minmax_top_left_bottom_right_min_max.rs b/tests/generated/absolute_minmax_top_left_bottom_right_min_max.rs index abb7c28e4..0216ad4e5 100644 --- a/tests/generated/absolute_minmax_top_left_bottom_right_min_max.rs +++ b/tests/generated/absolute_minmax_top_left_bottom_right_min_max.rs @@ -3,48 +3,44 @@ fn absolute_minmax_top_left_bottom_right_min_max() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), - }, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(30f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(30f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/absolute_padding_border_overrides_max_size.rs b/tests/generated/absolute_padding_border_overrides_max_size.rs index 33dd447bf..81aef047e 100644 --- a/tests/generated/absolute_padding_border_overrides_max_size.rs +++ b/tests/generated/absolute_padding_border_overrides_max_size.rs @@ -3,39 +3,37 @@ fn absolute_padding_border_overrides_max_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/absolute_padding_border_overrides_size.rs b/tests/generated/absolute_padding_border_overrides_size.rs index 7dc0ab03f..4f563bfbf 100644 --- a/tests/generated/absolute_padding_border_overrides_size.rs +++ b/tests/generated/absolute_padding_border_overrides_size.rs @@ -3,39 +3,37 @@ fn absolute_padding_border_overrides_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/align_baseline.rs b/tests/generated/align_baseline.rs index f7ed9ea04..3f552419b 100644 --- a/tests/generated/align_baseline.rs +++ b/tests/generated/align_baseline.rs @@ -3,52 +3,46 @@ fn align_baseline() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); diff --git a/tests/generated/align_baseline_child.rs b/tests/generated/align_baseline_child.rs index 82bf24b3c..364d759ab 100644 --- a/tests/generated/align_baseline_child.rs +++ b/tests/generated/align_baseline_child.rs @@ -3,70 +3,62 @@ fn align_baseline_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/align_baseline_child_margin.rs b/tests/generated/align_baseline_child_margin.rs index 18f25a9d6..8759987e2 100644 --- a/tests/generated/align_baseline_child_margin.rs +++ b/tests/generated/align_baseline_child_margin.rs @@ -3,82 +3,74 @@ fn align_baseline_child_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); diff --git a/tests/generated/align_baseline_child_margin_percent.rs b/tests/generated/align_baseline_child_margin_percent.rs index b183d984a..155c95a49 100644 --- a/tests/generated/align_baseline_child_margin_percent.rs +++ b/tests/generated/align_baseline_child_margin_percent.rs @@ -3,82 +3,74 @@ fn align_baseline_child_margin_percent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.01f32), + right: taffy::style::LengthPercentageAuto::Percent(0.01f32), + top: taffy::style::LengthPercentageAuto::Percent(0.01f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.01f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: taffy::style::LengthPercentageAuto::Percent(0.05f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.01f32), - right: taffy::style::LengthPercentageAuto::Percent(0.01f32), - top: taffy::style::LengthPercentageAuto::Percent(0.01f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.01f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node10, 1f32, location.x); diff --git a/tests/generated/align_baseline_child_multiline.rs b/tests/generated/align_baseline_child_multiline.rs index f33ea18e9..c4c1d0e70 100644 --- a/tests/generated/align_baseline_child_multiline.rs +++ b/tests/generated/align_baseline_child_multiline.rs @@ -3,106 +3,92 @@ fn align_baseline_child_multiline() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node11 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node12 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node13 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(20f32), - }, + }, + &[node10, node11, node12, node13], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node11 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node12 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node13 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node10, node11, node12, node13], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node12).unwrap(); + let Layout { size, location, .. } = taffy.layout(node12); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node13).unwrap(); + let Layout { size, location, .. } = taffy.layout(node13); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); diff --git a/tests/generated/align_baseline_child_multiline_no_override_on_secondline.rs b/tests/generated/align_baseline_child_multiline_no_override_on_secondline.rs index c64ce4b46..53b3b15fd 100644 --- a/tests/generated/align_baseline_child_multiline_no_override_on_secondline.rs +++ b/tests/generated/align_baseline_child_multiline_no_override_on_secondline.rs @@ -3,113 +3,99 @@ fn align_baseline_child_multiline_no_override_on_secondline() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node11 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node12 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node13 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Baseline), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(25f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10, node11, node12, node13], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node11 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node12 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node13 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(25f32), - }, - ..Default::default() - }, - &[node10, node11, node12, node13], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node12).unwrap(); + let Layout { size, location, .. } = taffy.layout(node12); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node13).unwrap(); + let Layout { size, location, .. } = taffy.layout(node13); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); diff --git a/tests/generated/align_baseline_child_multiline_override.rs b/tests/generated/align_baseline_child_multiline_override.rs index ee7a9d3ae..8469a0b90 100644 --- a/tests/generated/align_baseline_child_multiline_override.rs +++ b/tests/generated/align_baseline_child_multiline_override.rs @@ -3,114 +3,100 @@ fn align_baseline_child_multiline_override() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node11 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Baseline), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node12 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node13 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Baseline), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(25f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10, node11, node12, node13], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node11 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node12 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node13 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(25f32), - }, - ..Default::default() - }, - &[node10, node11, node12, node13], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node12).unwrap(); + let Layout { size, location, .. } = taffy.layout(node12); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node13).unwrap(); + let Layout { size, location, .. } = taffy.layout(node13); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); diff --git a/tests/generated/align_baseline_child_padding.rs b/tests/generated/align_baseline_child_padding.rs index 5ee601d04..2ac29bd99 100644 --- a/tests/generated/align_baseline_child_padding.rs +++ b/tests/generated/align_baseline_child_padding.rs @@ -3,82 +3,74 @@ fn align_baseline_child_padding() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), }, - ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(5f32), + right: taffy::style::LengthPercentage::Length(5f32), + top: taffy::style::LengthPercentage::Length(5f32), + bottom: taffy::style::LengthPercentage::Length(5f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(5f32), - right: taffy::style::LengthPercentage::Length(5f32), - top: taffy::style::LengthPercentage::Length(5f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(5f32), - right: taffy::style::LengthPercentage::Length(5f32), - top: taffy::style::LengthPercentage::Length(5f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(5f32), + right: taffy::style::LengthPercentage::Length(5f32), + top: taffy::style::LengthPercentage::Length(5f32), + bottom: taffy::style::LengthPercentage::Length(5f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); diff --git a/tests/generated/align_baseline_child_top.rs b/tests/generated/align_baseline_child_top.rs index 4957b2eb2..a7f24c730 100644 --- a/tests/generated/align_baseline_child_top.rs +++ b/tests/generated/align_baseline_child_top.rs @@ -3,76 +3,68 @@ fn align_baseline_child_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: auto(), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: auto(), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/align_baseline_child_top2.rs b/tests/generated/align_baseline_child_top2.rs index 92cfe0d32..d149b594c 100644 --- a/tests/generated/align_baseline_child_top2.rs +++ b/tests/generated/align_baseline_child_top2.rs @@ -3,75 +3,67 @@ fn align_baseline_child_top2() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: auto(), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: auto(), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/align_baseline_column.rs b/tests/generated/align_baseline_column.rs index 9782cc2c1..834ef784b 100644 --- a/tests/generated/align_baseline_column.rs +++ b/tests/generated/align_baseline_column.rs @@ -3,53 +3,47 @@ fn align_baseline_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/align_baseline_double_nested_child.rs b/tests/generated/align_baseline_double_nested_child.rs index 081ae54af..7d8897c0b 100644 --- a/tests/generated/align_baseline_double_nested_child.rs +++ b/tests/generated/align_baseline_double_nested_child.rs @@ -3,86 +3,76 @@ fn align_baseline_double_nested_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(50f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node00], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(15f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(15f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node10, 15f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/align_baseline_multiline.rs b/tests/generated/align_baseline_multiline.rs index f1edda44d..d48de5e00 100644 --- a/tests/generated/align_baseline_multiline.rs +++ b/tests/generated/align_baseline_multiline.rs @@ -3,117 +3,103 @@ fn align_baseline_multiline() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node20 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node20 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node20], - ) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { + }, + &[node20], + ); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node20).unwrap(); + let Layout { size, location, .. } = taffy.layout(node20); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); diff --git a/tests/generated/align_baseline_multiline_column.rs b/tests/generated/align_baseline_multiline_column.rs index e8009d660..bcc23f951 100644 --- a/tests/generated/align_baseline_multiline_column.rs +++ b/tests/generated/align_baseline_multiline_column.rs @@ -3,118 +3,104 @@ fn align_baseline_multiline_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(30f32), height: taffy::style::Dimension::Length(50f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node20 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(70f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node20 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(70f32), - }, - ..Default::default() - }, - &[node20], - ) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { + }, + &[node20], + ); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node2, 70f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node20).unwrap(); + let Layout { size, location, .. } = taffy.layout(node20); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node20, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); diff --git a/tests/generated/align_baseline_multiline_column2.rs b/tests/generated/align_baseline_multiline_column2.rs index b05937223..bef6779e3 100644 --- a/tests/generated/align_baseline_multiline_column2.rs +++ b/tests/generated/align_baseline_multiline_column2.rs @@ -3,122 +3,108 @@ fn align_baseline_multiline_column2() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(30f32), height: taffy::style::Dimension::Length(50f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node20 = taffy.new_leaf(taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(70f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node20 = taffy - .new_leaf(taffy::style::Style { + }, + &[node20], + ); + let node3 = taffy.new_leaf(taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(70f32), - }, - ..Default::default() - }, - &[node20], - ) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node2, 70f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node20).unwrap(); + let Layout { size, location, .. } = taffy.layout(node20); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node20, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); diff --git a/tests/generated/align_baseline_multiline_row_and_column.rs b/tests/generated/align_baseline_multiline_row_and_column.rs index 59d3934fe..29e6f8b8f 100644 --- a/tests/generated/align_baseline_multiline_row_and_column.rs +++ b/tests/generated/align_baseline_multiline_row_and_column.rs @@ -3,117 +3,103 @@ fn align_baseline_multiline_row_and_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: taffy::style::Dimension::Length(50f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node20 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node20 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node20], - ) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { + }, + &[node20], + ); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node20).unwrap(); + let Layout { size, location, .. } = taffy.layout(node20); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); diff --git a/tests/generated/align_baseline_nested_child.rs b/tests/generated/align_baseline_nested_child.rs index 01fc93357..ad45cc5b5 100644 --- a/tests/generated/align_baseline_nested_child.rs +++ b/tests/generated/align_baseline_nested_child.rs @@ -3,70 +3,62 @@ fn align_baseline_nested_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/align_baseline_nested_column.rs b/tests/generated/align_baseline_nested_column.rs index 93571481f..2fc1324a1 100644 --- a/tests/generated/align_baseline_nested_column.rs +++ b/tests/generated/align_baseline_nested_column.rs @@ -3,97 +3,85 @@ fn align_baseline_nested_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node100 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node100 = taffy.new_leaf(taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node101 = taffy.new_leaf(taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node10 = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(80f32), }, ..Default::default() - }) - .unwrap(); - let node101 = taffy - .new_leaf(taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, + }, + &[node100, node101], + ); + let node1 = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(40f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(80f32), - }, - ..Default::default() - }, - &[node100, node101], - ) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node10, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node100).unwrap(); + let Layout { size, location, .. } = taffy.layout(node100); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node100, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node101).unwrap(); + let Layout { size, location, .. } = taffy.layout(node101); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node101, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node101, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node101, 0f32, location.x); diff --git a/tests/generated/align_center_should_size_based_on_content.rs b/tests/generated/align_center_should_size_based_on_content.rs index a4738bf74..7b2249561 100644 --- a/tests/generated/align_center_should_size_based_on_content.rs +++ b/tests/generated/align_center_should_size_based_on_content.rs @@ -3,62 +3,57 @@ fn align_center_should_size_based_on_content() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Center), + flex_grow: 0f32, + flex_shrink: 1f32, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::Center), - flex_grow: 0f32, - flex_shrink: 1f32, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node000, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node000, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/align_content_flex_end.rs b/tests/generated/align_content_flex_end.rs index 926ae4bfa..0c58e2464 100644 --- a/tests/generated/align_content_flex_end.rs +++ b/tests/generated/align_content_flex_end.rs @@ -3,96 +3,84 @@ fn align_content_flex_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::FlexEnd), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::FlexEnd), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); diff --git a/tests/generated/align_content_flex_start.rs b/tests/generated/align_content_flex_start.rs index 640ba1abc..c3b32bf12 100644 --- a/tests/generated/align_content_flex_start.rs +++ b/tests/generated/align_content_flex_start.rs @@ -3,95 +3,83 @@ fn align_content_flex_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(130f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::FlexStart), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(130f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node, 130f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); diff --git a/tests/generated/align_content_flex_start_with_flex.rs b/tests/generated/align_content_flex_start_with_flex.rs index dccae05ed..7d73d0f6d 100644 --- a/tests/generated/align_content_flex_start_with_flex.rs +++ b/tests/generated/align_content_flex_start_with_flex.rs @@ -3,93 +3,81 @@ fn align_content_flex_start_with_flex() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Percent(0f32), + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::FlexStart), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node2, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); diff --git a/tests/generated/align_content_flex_start_without_height_on_children.rs b/tests/generated/align_content_flex_start_without_height_on_children.rs index b73d5931a..12d14319a 100644 --- a/tests/generated/align_content_flex_start_without_height_on_children.rs +++ b/tests/generated/align_content_flex_start_without_height_on_children.rs @@ -3,87 +3,75 @@ fn align_content_flex_start_without_height_on_children() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::FlexStart), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); diff --git a/tests/generated/align_content_not_stretch_with_align_items_stretch.rs b/tests/generated/align_content_not_stretch_with_align_items_stretch.rs index bb34f11ef..abca0ae75 100644 --- a/tests/generated/align_content_not_stretch_with_align_items_stretch.rs +++ b/tests/generated/align_content_not_stretch_with_align_items_stretch.rs @@ -3,75 +3,65 @@ fn align_content_not_stretch_with_align_items_stretch() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(272f32), + height: taffy::style::Dimension::Length(44f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node00], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(56f32), + height: taffy::style::Dimension::Length(44f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::FlexStart), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(272f32), - height: taffy::style::Dimension::Length(44f32), + width: taffy::style::Dimension::Length(328f32), + height: taffy::style::Dimension::Length(52f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - &[node00], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(56f32), - height: taffy::style::Dimension::Length(44f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::FlexStart), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(328f32), - height: taffy::style::Dimension::Length(52f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 328f32, "width of node {:?}. Expected {}. Actual {}", node, 328f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node0, 272f32, size.width); assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node0, 44f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 272f32, "width of node {:?}. Expected {}. Actual {}", node00, 272f32, size.width); assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node00, 44f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 56f32, "width of node {:?}. Expected {}. Actual {}", node1, 56f32, size.width); assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node1, 44f32, size.height); assert_eq!(location.x, 272f32, "x of node {:?}. Expected {}. Actual {}", node1, 272f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 56f32, "width of node {:?}. Expected {}. Actual {}", node10, 56f32, size.width); assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node10, 44f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/align_content_space_around_single_line.rs b/tests/generated/align_content_space_around_single_line.rs index 8b7116b96..dacbae5f4 100644 --- a/tests/generated/align_content_space_around_single_line.rs +++ b/tests/generated/align_content_space_around_single_line.rs @@ -3,108 +3,94 @@ fn align_content_space_around_single_line() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_content: Some(taffy::style::AlignContent::SpaceAround), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node0, 17f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 16f32, "width of node {:?}. Expected {}. Actual {}", node1, 16f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 17f32, "x of node {:?}. Expected {}. Actual {}", node1, 17f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node2, 17f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 33f32, "x of node {:?}. Expected {}. Actual {}", node2, 33f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node3, 17f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 16f32, "width of node {:?}. Expected {}. Actual {}", node4, 16f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node4, 67f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node5, 17f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); assert_eq!(location.x, 83f32, "x of node {:?}. Expected {}. Actual {}", node5, 83f32, location.x); diff --git a/tests/generated/align_content_space_around_wrapped.rs b/tests/generated/align_content_space_around_wrapped.rs index d6f3029d8..e2ba4fb0f 100644 --- a/tests/generated/align_content_space_around_wrapped.rs +++ b/tests/generated/align_content_space_around_wrapped.rs @@ -3,109 +3,95 @@ fn align_content_space_around_wrapped() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::SpaceAround), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); assert_eq!(location.y, 78f32, "y of node {:?}. Expected {}. Actual {}", node4, 78f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); diff --git a/tests/generated/align_content_space_between_single_line.rs b/tests/generated/align_content_space_between_single_line.rs index 05fa0bd12..0dd31c2e7 100644 --- a/tests/generated/align_content_space_between_single_line.rs +++ b/tests/generated/align_content_space_between_single_line.rs @@ -3,108 +3,94 @@ fn align_content_space_between_single_line() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_content: Some(taffy::style::AlignContent::SpaceBetween), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node3, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node4, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); diff --git a/tests/generated/align_content_space_between_wrapped.rs b/tests/generated/align_content_space_between_wrapped.rs index eff556460..999b14307 100644 --- a/tests/generated/align_content_space_between_wrapped.rs +++ b/tests/generated/align_content_space_between_wrapped.rs @@ -3,109 +3,95 @@ fn align_content_space_between_wrapped() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::SpaceBetween), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node4, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); diff --git a/tests/generated/align_content_space_evenly_single_line.rs b/tests/generated/align_content_space_evenly_single_line.rs index 9b547aeac..cfe366818 100644 --- a/tests/generated/align_content_space_evenly_single_line.rs +++ b/tests/generated/align_content_space_evenly_single_line.rs @@ -3,108 +3,94 @@ fn align_content_space_evenly_single_line() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_content: Some(taffy::style::AlignContent::SpaceEvenly), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_content: Some(taffy::style::AlignContent::SpaceEvenly), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node3, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node4, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); diff --git a/tests/generated/align_content_space_evenly_wrapped.rs b/tests/generated/align_content_space_evenly_wrapped.rs index 93516d9aa..fbd71f350 100644 --- a/tests/generated/align_content_space_evenly_wrapped.rs +++ b/tests/generated/align_content_space_evenly_wrapped.rs @@ -3,109 +3,95 @@ fn align_content_space_evenly_wrapped() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::SpaceEvenly), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::SpaceEvenly), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node0, 18f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node1, 18f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); assert_eq!(location.y, 73f32, "y of node {:?}. Expected {}. Actual {}", node4, 73f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x); diff --git a/tests/generated/align_content_spacearound.rs b/tests/generated/align_content_spacearound.rs index 5f14f2b5a..882cc96cd 100644 --- a/tests/generated/align_content_spacearound.rs +++ b/tests/generated/align_content_spacearound.rs @@ -3,95 +3,83 @@ fn align_content_spacearound() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(140f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::SpaceAround), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(140f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node, 140f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node1, 15f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node2, 55f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node3, 55f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); diff --git a/tests/generated/align_content_spacebetween.rs b/tests/generated/align_content_spacebetween.rs index 17e7e3018..642347ea9 100644 --- a/tests/generated/align_content_spacebetween.rs +++ b/tests/generated/align_content_spacebetween.rs @@ -3,95 +3,83 @@ fn align_content_spacebetween() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(130f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::SpaceBetween), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(130f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node, 130f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); diff --git a/tests/generated/align_content_stretch.rs b/tests/generated/align_content_stretch.rs index d00bebce8..c4658e32f 100644 --- a/tests/generated/align_content_stretch.rs +++ b/tests/generated/align_content_stretch.rs @@ -3,81 +3,69 @@ fn align_content_stretch() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); diff --git a/tests/generated/align_content_stretch_column.rs b/tests/generated/align_content_stretch_column.rs index b71d61da9..49a8a9072 100644 --- a/tests/generated/align_content_stretch_column.rs +++ b/tests/generated/align_content_stretch_column.rs @@ -3,101 +3,87 @@ fn align_content_stretch_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), + let node00 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(150f32), - }, - ..Default::default() + }, + &[node00], + ); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(150f32), }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node, 150f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node3, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); diff --git a/tests/generated/align_content_stretch_is_not_overriding_align_items.rs b/tests/generated/align_content_stretch_is_not_overriding_align_items.rs index 086869506..bf74e9216 100644 --- a/tests/generated/align_content_stretch_is_not_overriding_align_items.rs +++ b/tests/generated/align_content_stretch_is_not_overriding_align_items.rs @@ -3,51 +3,45 @@ fn align_content_stretch_is_not_overriding_align_items() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/align_content_stretch_row.rs b/tests/generated/align_content_stretch_row.rs index eb57bd93a..9d2a6b856 100644 --- a/tests/generated/align_content_stretch_row.rs +++ b/tests/generated/align_content_stretch_row.rs @@ -3,80 +3,68 @@ fn align_content_stretch_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); diff --git a/tests/generated/align_content_stretch_row_with_children.rs b/tests/generated/align_content_stretch_row_with_children.rs index 4d7ce8b78..fce98e7e7 100644 --- a/tests/generated/align_content_stretch_row_with_children.rs +++ b/tests/generated/align_content_stretch_row_with_children.rs @@ -3,97 +3,83 @@ fn align_content_stretch_row_with_children() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + }, + &[node00], + ); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); diff --git a/tests/generated/align_content_stretch_row_with_fixed_height.rs b/tests/generated/align_content_stretch_row_with_fixed_height.rs index 18c35e35d..c74c760f1 100644 --- a/tests/generated/align_content_stretch_row_with_fixed_height.rs +++ b/tests/generated/align_content_stretch_row_with_fixed_height.rs @@ -3,83 +3,71 @@ fn align_content_stretch_row_with_fixed_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node2, 80f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); diff --git a/tests/generated/align_content_stretch_row_with_flex.rs b/tests/generated/align_content_stretch_row_with_flex.rs index b692d0717..44923159b 100644 --- a/tests/generated/align_content_stretch_row_with_flex.rs +++ b/tests/generated/align_content_stretch_row_with_flex.rs @@ -3,86 +3,74 @@ fn align_content_stretch_row_with_flex() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node3, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node4, 100f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); diff --git a/tests/generated/align_content_stretch_row_with_flex_no_shrink.rs b/tests/generated/align_content_stretch_row_with_flex_no_shrink.rs index 1b67d19fd..3de40d04c 100644 --- a/tests/generated/align_content_stretch_row_with_flex_no_shrink.rs +++ b/tests/generated/align_content_stretch_row_with_flex_no_shrink.rs @@ -3,86 +3,74 @@ fn align_content_stretch_row_with_flex_no_shrink() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node3, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node4, 100f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); diff --git a/tests/generated/align_content_stretch_row_with_margin.rs b/tests/generated/align_content_stretch_row_with_margin.rs index fbd7f080d..1e719f520 100644 --- a/tests/generated/align_content_stretch_row_with_margin.rs +++ b/tests/generated/align_content_stretch_row_with_margin.rs @@ -3,92 +3,80 @@ fn align_content_stretch_row_with_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); diff --git a/tests/generated/align_content_stretch_row_with_max_height.rs b/tests/generated/align_content_stretch_row_with_max_height.rs index f9f0366c3..c942f9be0 100644 --- a/tests/generated/align_content_stretch_row_with_max_height.rs +++ b/tests/generated/align_content_stretch_row_with_max_height.rs @@ -3,81 +3,69 @@ fn align_content_stretch_row_with_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); diff --git a/tests/generated/align_content_stretch_row_with_min_height.rs b/tests/generated/align_content_stretch_row_with_min_height.rs index bd7505acc..97a7062ae 100644 --- a/tests/generated/align_content_stretch_row_with_min_height.rs +++ b/tests/generated/align_content_stretch_row_with_min_height.rs @@ -3,81 +3,69 @@ fn align_content_stretch_row_with_min_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(80f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(80f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node0, 90f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node1, 90f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node2, 90f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node3, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); diff --git a/tests/generated/align_content_stretch_row_with_padding.rs b/tests/generated/align_content_stretch_row_with_padding.rs index a97f796aa..b7ef4773a 100644 --- a/tests/generated/align_content_stretch_row_with_padding.rs +++ b/tests/generated/align_content_stretch_row_with_padding.rs @@ -3,92 +3,80 @@ fn align_content_stretch_row_with_padding() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); diff --git a/tests/generated/align_content_stretch_row_with_single_row.rs b/tests/generated/align_content_stretch_row_with_single_row.rs index 0f0fd261d..a3cc2a1c9 100644 --- a/tests/generated/align_content_stretch_row_with_single_row.rs +++ b/tests/generated/align_content_stretch_row_with_single_row.rs @@ -3,47 +3,41 @@ fn align_content_stretch_row_with_single_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); diff --git a/tests/generated/align_flex_start_with_shrinking_children.rs b/tests/generated/align_flex_start_with_shrinking_children.rs index 65cf55d8f..4d62a3695 100644 --- a/tests/generated/align_flex_start_with_shrinking_children.rs +++ b/tests/generated/align_flex_start_with_shrinking_children.rs @@ -3,49 +3,45 @@ fn align_flex_start_with_shrinking_children() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = - taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); - let node00 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { align_items: Some(taffy::style::AlignItems::FlexStart), ..Default::default() }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(500f32), - height: taffy::style::Dimension::Length(500f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }); + let node00 = taffy.new_with_children( + taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { align_items: Some(taffy::style::AlignItems::FlexStart), ..Default::default() }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(500f32), + height: taffy::style::Dimension::Length(500f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node0, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/align_flex_start_with_shrinking_children_with_stretch.rs b/tests/generated/align_flex_start_with_shrinking_children_with_stretch.rs index 244989757..17d73dfa9 100644 --- a/tests/generated/align_flex_start_with_shrinking_children_with_stretch.rs +++ b/tests/generated/align_flex_start_with_shrinking_children_with_stretch.rs @@ -3,57 +3,50 @@ fn align_flex_start_with_shrinking_children_with_stretch() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = - taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Stretch), - flex_grow: 1f32, - flex_shrink: 1f32, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }); + let node00 = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Stretch), + flex_grow: 1f32, + flex_shrink: 1f32, + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { align_items: Some(taffy::style::AlignItems::FlexStart), ..Default::default() }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(500f32), + height: taffy::style::Dimension::Length(500f32), }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { align_items: Some(taffy::style::AlignItems::FlexStart), ..Default::default() }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(500f32), - height: taffy::style::Dimension::Length(500f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node0, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/align_flex_start_with_stretching_children.rs b/tests/generated/align_flex_start_with_stretching_children.rs index b226615f8..d81db2a93 100644 --- a/tests/generated/align_flex_start_with_stretching_children.rs +++ b/tests/generated/align_flex_start_with_stretching_children.rs @@ -3,44 +3,42 @@ fn align_flex_start_with_stretching_children() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = - taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); - let node00 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) - .unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(500f32), - height: taffy::style::Dimension::Length(500f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }); + let node00 = taffy.new_with_children( + taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[node000], + ); + let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(500f32), + height: taffy::style::Dimension::Length(500f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node0, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node00, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node000, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/align_items_center.rs b/tests/generated/align_items_center.rs index 0a84a7295..7792b3d19 100644 --- a/tests/generated/align_items_center.rs +++ b/tests/generated/align_items_center.rs @@ -3,38 +3,34 @@ fn align_items_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/align_items_center_child_with_margin_bigger_than_parent.rs b/tests/generated/align_items_center_child_with_margin_bigger_than_parent.rs index 8872eecd8..f86890dd6 100644 --- a/tests/generated/align_items_center_child_with_margin_bigger_than_parent.rs +++ b/tests/generated/align_items_center_child_with_margin_bigger_than_parent.rs @@ -3,56 +3,50 @@ fn align_items_center_child_with_margin_bigger_than_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { align_items: Some(taffy::style::AlignItems::Center), ..Default::default() }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: taffy::style::Dimension::Length(50f32), }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: zero(), - bottom: zero(), - }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { align_items: Some(taffy::style::AlignItems::Center), ..Default::default() }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node00, 10f32, location.x); diff --git a/tests/generated/align_items_center_child_without_margin_bigger_than_parent.rs b/tests/generated/align_items_center_child_without_margin_bigger_than_parent.rs index 11b4e8653..90ffd3f5e 100644 --- a/tests/generated/align_items_center_child_without_margin_bigger_than_parent.rs +++ b/tests/generated/align_items_center_child_without_margin_bigger_than_parent.rs @@ -3,50 +3,44 @@ fn align_items_center_child_without_margin_bigger_than_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(70f32), + height: taffy::style::Dimension::Length(70f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { align_items: Some(taffy::style::AlignItems::Center), ..Default::default() }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(70f32), - height: taffy::style::Dimension::Length(70f32), + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { align_items: Some(taffy::style::AlignItems::Center), ..Default::default() }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node0, 70f32, size.height); assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node00, 70f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/align_items_center_justify_content_center.rs b/tests/generated/align_items_center_justify_content_center.rs index 91ba2f30f..84aa41c81 100644 --- a/tests/generated/align_items_center_justify_content_center.rs +++ b/tests/generated/align_items_center_justify_content_center.rs @@ -3,90 +3,76 @@ fn align_items_center_justify_content_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf_with_measure( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf_with_measure( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "\n "; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: zero(), - bottom: zero(), - }, - ..Default::default() + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "\n "; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node00 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: zero(), + bottom: zero(), }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(500f32), + height: taffy::style::Dimension::Length(500f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(500f32), - height: taffy::style::Dimension::Length(500f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node0, 500f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); assert_eq!(location.x, 245f32, "x of node {:?}. Expected {}. Actual {}", node00, 245f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node000, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/align_items_center_min_max_with_padding.rs b/tests/generated/align_items_center_min_max_with_padding.rs index 046bd66a3..3b4d038f5 100644 --- a/tests/generated/align_items_center_min_max_with_padding.rs +++ b/tests/generated/align_items_center_min_max_with_padding.rs @@ -3,48 +3,44 @@ fn align_items_center_min_max_with_padding() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(62f32), - height: taffy::style::Dimension::Length(62f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(62f32), + height: taffy::style::Dimension::Length(62f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(320f32), + height: taffy::style::Dimension::Length(72f32), }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(320f32), - height: taffy::style::Dimension::Length(72f32), - }, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(320f32), - height: taffy::style::Dimension::Length(504f32), - }, - padding: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentage::Length(8f32), - bottom: taffy::style::LengthPercentage::Length(8f32), - }, - ..Default::default() + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(320f32), + height: taffy::style::Dimension::Length(504f32), + }, + padding: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentage::Length(8f32), + bottom: taffy::style::LengthPercentage::Length(8f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); assert_eq!(size.height, 78f32, "height of node {:?}. Expected {}. Actual {}", node, 78f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node0, 62f32, size.width); assert_eq!(size.height, 62f32, "height of node {:?}. Expected {}. Actual {}", node0, 62f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/align_items_center_with_child_margin.rs b/tests/generated/align_items_center_with_child_margin.rs index d3d38be0d..abae036e0 100644 --- a/tests/generated/align_items_center_with_child_margin.rs +++ b/tests/generated/align_items_center_with_child_margin.rs @@ -3,44 +3,40 @@ fn align_items_center_with_child_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/align_items_center_with_child_top.rs b/tests/generated/align_items_center_with_child_top.rs index 089bbf625..5ea881351 100644 --- a/tests/generated/align_items_center_with_child_top.rs +++ b/tests/generated/align_items_center_with_child_top.rs @@ -3,44 +3,40 @@ fn align_items_center_with_child_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: auto(), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/align_items_flex_end.rs b/tests/generated/align_items_flex_end.rs index 225793e96..8a4199a5a 100644 --- a/tests/generated/align_items_flex_end.rs +++ b/tests/generated/align_items_flex_end.rs @@ -3,38 +3,34 @@ fn align_items_flex_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::FlexEnd), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::FlexEnd), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs b/tests/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs index 66058782d..67326db02 100644 --- a/tests/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs +++ b/tests/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs @@ -3,56 +3,50 @@ fn align_items_flex_end_child_with_margin_bigger_than_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { align_items: Some(taffy::style::AlignItems::FlexEnd), ..Default::default() }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: taffy::style::Dimension::Length(50f32), }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: zero(), - bottom: zero(), - }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { align_items: Some(taffy::style::AlignItems::FlexEnd), ..Default::default() }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node00, 10f32, location.x); diff --git a/tests/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs b/tests/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs index dfcbfff5b..5ec2962b1 100644 --- a/tests/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs +++ b/tests/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs @@ -3,50 +3,44 @@ fn align_items_flex_end_child_without_margin_bigger_than_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(70f32), + height: taffy::style::Dimension::Length(70f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { align_items: Some(taffy::style::AlignItems::FlexEnd), ..Default::default() }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(70f32), - height: taffy::style::Dimension::Length(70f32), + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { align_items: Some(taffy::style::AlignItems::FlexEnd), ..Default::default() }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node0, 70f32, size.height); assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node00, 70f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/align_items_flex_start.rs b/tests/generated/align_items_flex_start.rs index c37316871..4b0348ce7 100644 --- a/tests/generated/align_items_flex_start.rs +++ b/tests/generated/align_items_flex_start.rs @@ -3,38 +3,34 @@ fn align_items_flex_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::FlexStart), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/align_items_min_max.rs b/tests/generated/align_items_min_max.rs index c40123e94..47fb749d2 100644 --- a/tests/generated/align_items_min_max.rs +++ b/tests/generated/align_items_min_max.rs @@ -3,38 +3,34 @@ fn align_items_min_max() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Center), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); diff --git a/tests/generated/align_items_stretch.rs b/tests/generated/align_items_stretch.rs index a2790385c..aaeccda95 100644 --- a/tests/generated/align_items_stretch.rs +++ b/tests/generated/align_items_stretch.rs @@ -3,34 +3,30 @@ fn align_items_stretch() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/align_items_stretch_min_cross.rs b/tests/generated/align_items_stretch_min_cross.rs index 8d472005d..cf076c475 100644 --- a/tests/generated/align_items_stretch_min_cross.rs +++ b/tests/generated/align_items_stretch_min_cross.rs @@ -3,36 +3,32 @@ fn align_items_stretch_min_cross() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(36f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(36f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node0, 400f32, size.width); assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node0, 36f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/align_self_baseline.rs b/tests/generated/align_self_baseline.rs index 8baca98aa..f8cfbb856 100644 --- a/tests/generated/align_self_baseline.rs +++ b/tests/generated/align_self_baseline.rs @@ -3,70 +3,62 @@ fn align_self_baseline() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Baseline), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/align_self_center.rs b/tests/generated/align_self_center.rs index 9054d4a56..1eb486786 100644 --- a/tests/generated/align_self_center.rs +++ b/tests/generated/align_self_center.rs @@ -3,38 +3,34 @@ fn align_self_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Center), + let node0 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/align_self_center_undefined_max_height.rs b/tests/generated/align_self_center_undefined_max_height.rs index 89862fbcd..7b8530284 100644 --- a/tests/generated/align_self_center_undefined_max_height.rs +++ b/tests/generated/align_self_center_undefined_max_height.rs @@ -3,50 +3,44 @@ fn align_self_center_undefined_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(240f32), - height: taffy::style::Dimension::Length(44f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(240f32), + height: taffy::style::Dimension::Length(44f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(56f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(280f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(52f32) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(56f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(280f32), height: auto() }, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(52f32) }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 280f32, "width of node {:?}. Expected {}. Actual {}", node, 280f32, size.width); assert_eq!(size.height, 56f32, "height of node {:?}. Expected {}. Actual {}", node, 56f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node0, 240f32, size.width); assert_eq!(size.height, 44f32, "height of node {:?}. Expected {}. Actual {}", node0, 44f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 56f32, "height of node {:?}. Expected {}. Actual {}", node1, 56f32, size.height); assert_eq!(location.x, 240f32, "x of node {:?}. Expected {}. Actual {}", node1, 240f32, location.x); diff --git a/tests/generated/align_self_flex_end.rs b/tests/generated/align_self_flex_end.rs index 52073864a..af9a798ab 100644 --- a/tests/generated/align_self_flex_end.rs +++ b/tests/generated/align_self_flex_end.rs @@ -3,38 +3,34 @@ fn align_self_flex_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::FlexEnd), + let node0 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::FlexEnd), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/align_self_flex_end_override_flex_start.rs b/tests/generated/align_self_flex_end_override_flex_start.rs index e0c0dce38..8c731976e 100644 --- a/tests/generated/align_self_flex_end_override_flex_start.rs +++ b/tests/generated/align_self_flex_end_override_flex_start.rs @@ -3,39 +3,35 @@ fn align_self_flex_end_override_flex_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::FlexEnd), + let node0 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::FlexEnd), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::FlexStart), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/align_self_flex_start.rs b/tests/generated/align_self_flex_start.rs index decaad02d..fa64e730a 100644 --- a/tests/generated/align_self_flex_start.rs +++ b/tests/generated/align_self_flex_start.rs @@ -3,38 +3,34 @@ fn align_self_flex_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::FlexStart), + let node0 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::FlexStart), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/align_stretch_should_size_based_on_parent.rs b/tests/generated/align_stretch_should_size_based_on_parent.rs index 3a101ee02..5532e295b 100644 --- a/tests/generated/align_stretch_should_size_based_on_parent.rs +++ b/tests/generated/align_stretch_should_size_based_on_parent.rs @@ -3,61 +3,56 @@ fn align_stretch_should_size_based_on_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Center), + flex_grow: 0f32, + flex_shrink: 1f32, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::Center), - flex_grow: 0f32, - flex_shrink: 1f32, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node000, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node000, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/android_news_feed.rs b/tests/generated/android_news_feed.rs index edbb5c7fe..a41c8346f 100644 --- a/tests/generated/android_news_feed.rs +++ b/tests/generated/android_news_feed.rs @@ -3,291 +3,257 @@ fn android_news_feed() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000000 = taffy - .new_leaf(taffy::style::Style { + let node000000 = taffy.new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), + }, + ..Default::default() + }); + let node00000 = taffy.new_with_children( + taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), + ..Default::default() + }, + &[node000000], + ); + let node000010 = taffy.new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + flex_shrink: 1f32, + ..Default::default() + }); + let node000011 = taffy.new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + flex_shrink: 1f32, + ..Default::default() + }); + let node00001 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_content: Some(taffy::style::AlignContent::Stretch), + flex_shrink: 1f32, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Length(36f32), + top: zero(), + bottom: zero(), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(36f32), + right: taffy::style::LengthPercentage::Length(36f32), + top: taffy::style::LengthPercentage::Length(21f32), + bottom: taffy::style::LengthPercentage::Length(18f32), }, ..Default::default() - }) - .unwrap(); - let node00000 = taffy - .new_with_children( - taffy::style::Style { - align_content: Some(taffy::style::AlignContent::Stretch), - flex_shrink: 0f32, - ..Default::default() + }, + &[node000010, node000011], + ); + let node0000 = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::FlexStart), + align_content: Some(taffy::style::AlignContent::Stretch), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(36f32), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(24f32), + bottom: zero(), }, - &[node000000], - ) - .unwrap(); - let node000010 = taffy - .new_leaf(taffy::style::Style { + ..Default::default() + }, + &[node00000, node00001], + ); + let node000 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, align_content: Some(taffy::style::AlignContent::Stretch), - flex_shrink: 1f32, ..Default::default() - }) - .unwrap(); - let node000011 = taffy - .new_leaf(taffy::style::Style { + }, + &[node0000], + ); + let node001000 = taffy.new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(72f32), + height: taffy::style::Dimension::Length(72f32), + }, + ..Default::default() + }); + let node00100 = taffy.new_with_children( + taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), - flex_shrink: 1f32, + flex_shrink: 0f32, ..Default::default() - }) - .unwrap(); - let node00001 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_content: Some(taffy::style::AlignContent::Stretch), - flex_shrink: 1f32, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Length(36f32), - top: zero(), - bottom: zero(), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(36f32), - right: taffy::style::LengthPercentage::Length(36f32), - top: taffy::style::LengthPercentage::Length(21f32), - bottom: taffy::style::LengthPercentage::Length(18f32), - }, - ..Default::default() - }, - &[node000010, node000011], - ) - .unwrap(); - let node0000 = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::FlexStart), - align_content: Some(taffy::style::AlignContent::Stretch), - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(36f32), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(24f32), - bottom: zero(), - }, - ..Default::default() + }, + &[node001000], + ); + let node001010 = taffy.new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + flex_shrink: 1f32, + ..Default::default() + }); + let node001011 = taffy.new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + flex_shrink: 1f32, + ..Default::default() + }); + let node00101 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_content: Some(taffy::style::AlignContent::Stretch), + flex_shrink: 1f32, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Length(36f32), + top: zero(), + bottom: zero(), }, - &[node00000, node00001], - ) - .unwrap(); - let node000 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_content: Some(taffy::style::AlignContent::Stretch), - ..Default::default() + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(36f32), + right: taffy::style::LengthPercentage::Length(36f32), + top: taffy::style::LengthPercentage::Length(21f32), + bottom: taffy::style::LengthPercentage::Length(18f32), }, - &[node0000], - ) - .unwrap(); - let node001000 = taffy - .new_leaf(taffy::style::Style { + ..Default::default() + }, + &[node001010, node001011], + ); + let node0010 = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::FlexStart), align_content: Some(taffy::style::AlignContent::Stretch), - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(72f32), - height: taffy::style::Dimension::Length(72f32), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(174f32), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(24f32), + bottom: zero(), }, ..Default::default() - }) - .unwrap(); - let node00100 = taffy - .new_with_children( - taffy::style::Style { - align_content: Some(taffy::style::AlignContent::Stretch), - flex_shrink: 0f32, - ..Default::default() - }, - &[node001000], - ) - .unwrap(); - let node001010 = taffy - .new_leaf(taffy::style::Style { + }, + &[node00100, node00101], + ); + let node001 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, align_content: Some(taffy::style::AlignContent::Stretch), - flex_shrink: 1f32, ..Default::default() - }) - .unwrap(); - let node001011 = taffy - .new_leaf(taffy::style::Style { + }, + &[node0010], + ); + let node00 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, align_content: Some(taffy::style::AlignContent::Stretch), - flex_shrink: 1f32, ..Default::default() - }) - .unwrap(); - let node00101 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_content: Some(taffy::style::AlignContent::Stretch), - flex_shrink: 1f32, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Length(36f32), - top: zero(), - bottom: zero(), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(36f32), - right: taffy::style::LengthPercentage::Length(36f32), - top: taffy::style::LengthPercentage::Length(21f32), - bottom: taffy::style::LengthPercentage::Length(18f32), - }, - ..Default::default() - }, - &[node001010, node001011], - ) - .unwrap(); - let node0010 = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::FlexStart), - align_content: Some(taffy::style::AlignContent::Stretch), - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(174f32), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(24f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node00100, node00101], - ) - .unwrap(); - let node001 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_content: Some(taffy::style::AlignContent::Stretch), - ..Default::default() - }, - &[node0010], - ) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_content: Some(taffy::style::AlignContent::Stretch), - ..Default::default() - }, - &[node000, node001], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_shrink: 0f32, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_content: Some(taffy::style::AlignContent::Stretch), - flex_shrink: 0f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(1080f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node000, node001], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_shrink: 0f32, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_content: Some(taffy::style::AlignContent::Stretch), + flex_shrink: 0f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(1080f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node, 1080f32, size.width); assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node0, 1080f32, size.width); assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node00, 1080f32, size.width); assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node00, 240f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node000, 1080f32, size.width); assert_eq!(size.height, 144f32, "height of node {:?}. Expected {}. Actual {}", node000, 144f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0000); assert_eq!(size.width, 1044f32, "width of node {:?}. Expected {}. Actual {}", node0000, 1044f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0000, 120f32, size.height); assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node0000, 36f32, location.x); assert_eq!(location.y, 24f32, "y of node {:?}. Expected {}. Actual {}", node0000, 24f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00000); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node00000, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node00000, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000000); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node000000, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node000000, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00001).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00001); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00001, 72f32, size.width); assert_eq!(size.height, 39f32, "height of node {:?}. Expected {}. Actual {}", node00001, 39f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node00001, 120f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00001, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000010).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000010); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000010, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000010, 0f32, size.height); assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node000010, 36f32, location.x); assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node000010, 21f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000011).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000011); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000011, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000011, 0f32, size.height); assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node000011, 36f32, location.x); assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node000011, 21f32, location.y); - let Layout { size, location, .. } = taffy.layout(node001).unwrap(); + let Layout { size, location, .. } = taffy.layout(node001); assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node001, 1080f32, size.width); assert_eq!(size.height, 96f32, "height of node {:?}. Expected {}. Actual {}", node001, 96f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node001, 0f32, location.x); assert_eq!(location.y, 144f32, "y of node {:?}. Expected {}. Actual {}", node001, 144f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0010).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0010); assert_eq!(size.width, 906f32, "width of node {:?}. Expected {}. Actual {}", node0010, 906f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0010, 72f32, size.height); assert_eq!(location.x, 174f32, "x of node {:?}. Expected {}. Actual {}", node0010, 174f32, location.x); assert_eq!(location.y, 24f32, "y of node {:?}. Expected {}. Actual {}", node0010, 24f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00100).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00100); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00100, 72f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node00100, 72f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node001000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node001000); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node001000, 72f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node001000, 72f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node001000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node001000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00101).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00101); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00101, 72f32, size.width); assert_eq!(size.height, 39f32, "height of node {:?}. Expected {}. Actual {}", node00101, 39f32, size.height); assert_eq!(location.x, 72f32, "x of node {:?}. Expected {}. Actual {}", node00101, 72f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00101, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node001010).unwrap(); + let Layout { size, location, .. } = taffy.layout(node001010); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node001010, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node001010, 0f32, size.height); assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node001010, 36f32, location.x); assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node001010, 21f32, location.y); - let Layout { size, location, .. } = taffy.layout(node001011).unwrap(); + let Layout { size, location, .. } = taffy.layout(node001011); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node001011, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node001011, 0f32, size.height); assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node001011, 36f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_column_fill_height.rs b/tests/generated/aspect_ratio_flex_column_fill_height.rs index 843969ba9..ce16f7724 100644 --- a/tests/generated/aspect_ratio_flex_column_fill_height.rs +++ b/tests/generated/aspect_ratio_flex_column_fill_height.rs @@ -3,38 +3,34 @@ fn aspect_ratio_flex_column_fill_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_column_fill_max_height.rs b/tests/generated/aspect_ratio_flex_column_fill_max_height.rs index 72d61b53f..2a9a14f7c 100644 --- a/tests/generated/aspect_ratio_flex_column_fill_max_height.rs +++ b/tests/generated/aspect_ratio_flex_column_fill_max_height.rs @@ -3,32 +3,30 @@ fn aspect_ratio_flex_column_fill_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ; - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) ; + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_column_fill_max_width.rs b/tests/generated/aspect_ratio_flex_column_fill_max_width.rs index 31d6e6e12..c0ca73574 100644 --- a/tests/generated/aspect_ratio_flex_column_fill_max_width.rs +++ b/tests/generated/aspect_ratio_flex_column_fill_max_width.rs @@ -3,50 +3,46 @@ fn aspect_ratio_flex_column_fill_max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - aspect_ratio: Some(2f32), - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - Some(2f32), - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_column_fill_min_height.rs b/tests/generated/aspect_ratio_flex_column_fill_min_height.rs index 6e70a2ff1..c83738d5a 100644 --- a/tests/generated/aspect_ratio_flex_column_fill_min_height.rs +++ b/tests/generated/aspect_ratio_flex_column_fill_min_height.rs @@ -3,38 +3,34 @@ fn aspect_ratio_flex_column_fill_min_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_column_fill_min_width.rs b/tests/generated/aspect_ratio_flex_column_fill_min_width.rs index aef83bb66..ccf4adf38 100644 --- a/tests/generated/aspect_ratio_flex_column_fill_min_width.rs +++ b/tests/generated/aspect_ratio_flex_column_fill_min_width.rs @@ -3,50 +3,46 @@ fn aspect_ratio_flex_column_fill_min_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, - aspect_ratio: Some(2f32), - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "\n \n "; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "\n \n "; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - Some(2f32), - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_column_fill_width.rs b/tests/generated/aspect_ratio_flex_column_fill_width.rs index 0fd3c694f..a0701a858 100644 --- a/tests/generated/aspect_ratio_flex_column_fill_width.rs +++ b/tests/generated/aspect_ratio_flex_column_fill_width.rs @@ -3,38 +3,34 @@ fn aspect_ratio_flex_column_fill_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_column_fill_width_flex.rs b/tests/generated/aspect_ratio_flex_column_fill_width_flex.rs index b91001e0e..cec9b2ccc 100644 --- a/tests/generated/aspect_ratio_flex_column_fill_width_flex.rs +++ b/tests/generated/aspect_ratio_flex_column_fill_width_flex.rs @@ -3,37 +3,33 @@ fn aspect_ratio_flex_column_fill_width_flex() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_column_stretch_fill_height.rs b/tests/generated/aspect_ratio_flex_column_stretch_fill_height.rs index 21adbd2db..8631de00a 100644 --- a/tests/generated/aspect_ratio_flex_column_stretch_fill_height.rs +++ b/tests/generated/aspect_ratio_flex_column_stretch_fill_height.rs @@ -3,37 +3,33 @@ fn aspect_ratio_flex_column_stretch_fill_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_column_stretch_fill_max_height.rs b/tests/generated/aspect_ratio_flex_column_stretch_fill_max_height.rs index 55e050f25..a100d11b5 100644 --- a/tests/generated/aspect_ratio_flex_column_stretch_fill_max_height.rs +++ b/tests/generated/aspect_ratio_flex_column_stretch_fill_max_height.rs @@ -3,31 +3,29 @@ fn aspect_ratio_flex_column_stretch_fill_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ; - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) ; + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_column_stretch_fill_max_width.rs b/tests/generated/aspect_ratio_flex_column_stretch_fill_max_width.rs index a893eee43..819087ef1 100644 --- a/tests/generated/aspect_ratio_flex_column_stretch_fill_max_width.rs +++ b/tests/generated/aspect_ratio_flex_column_stretch_fill_max_width.rs @@ -3,49 +3,45 @@ fn aspect_ratio_flex_column_stretch_fill_max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - aspect_ratio: Some(2f32), - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - Some(2f32), - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_column_stretch_fill_width.rs b/tests/generated/aspect_ratio_flex_column_stretch_fill_width.rs index 91dd1352a..fbda0a13c 100644 --- a/tests/generated/aspect_ratio_flex_column_stretch_fill_width.rs +++ b/tests/generated/aspect_ratio_flex_column_stretch_fill_width.rs @@ -3,37 +3,33 @@ fn aspect_ratio_flex_column_stretch_fill_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_row_fill_height.rs b/tests/generated/aspect_ratio_flex_row_fill_height.rs index 69e74ab20..0d6acb9b9 100644 --- a/tests/generated/aspect_ratio_flex_row_fill_height.rs +++ b/tests/generated/aspect_ratio_flex_row_fill_height.rs @@ -3,37 +3,33 @@ fn aspect_ratio_flex_row_fill_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_row_fill_max_height.rs b/tests/generated/aspect_ratio_flex_row_fill_max_height.rs index ead89fa20..556a2535e 100644 --- a/tests/generated/aspect_ratio_flex_row_fill_max_height.rs +++ b/tests/generated/aspect_ratio_flex_row_fill_max_height.rs @@ -3,31 +3,29 @@ fn aspect_ratio_flex_row_fill_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ; - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) ; + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_row_fill_max_width.rs b/tests/generated/aspect_ratio_flex_row_fill_max_width.rs index cd2e6dff1..4e62ce863 100644 --- a/tests/generated/aspect_ratio_flex_row_fill_max_width.rs +++ b/tests/generated/aspect_ratio_flex_row_fill_max_width.rs @@ -3,49 +3,45 @@ fn aspect_ratio_flex_row_fill_max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - aspect_ratio: Some(2f32), - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - Some(2f32), - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_row_fill_min_height.rs b/tests/generated/aspect_ratio_flex_row_fill_min_height.rs index 75972828d..789d9ca25 100644 --- a/tests/generated/aspect_ratio_flex_row_fill_min_height.rs +++ b/tests/generated/aspect_ratio_flex_row_fill_min_height.rs @@ -3,37 +3,33 @@ fn aspect_ratio_flex_row_fill_min_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_row_fill_min_width.rs b/tests/generated/aspect_ratio_flex_row_fill_min_width.rs index 6bc68b333..be655af4b 100644 --- a/tests/generated/aspect_ratio_flex_row_fill_min_width.rs +++ b/tests/generated/aspect_ratio_flex_row_fill_min_width.rs @@ -3,49 +3,45 @@ fn aspect_ratio_flex_row_fill_min_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, - aspect_ratio: Some(2f32), - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "\n \n "; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "\n \n "; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - Some(2f32), - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_row_fill_width.rs b/tests/generated/aspect_ratio_flex_row_fill_width.rs index 4ee953c7f..7b4292333 100644 --- a/tests/generated/aspect_ratio_flex_row_fill_width.rs +++ b/tests/generated/aspect_ratio_flex_row_fill_width.rs @@ -3,37 +3,33 @@ fn aspect_ratio_flex_row_fill_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_row_fill_width_flex.rs b/tests/generated/aspect_ratio_flex_row_fill_width_flex.rs index b821fc3c2..296d89352 100644 --- a/tests/generated/aspect_ratio_flex_row_fill_width_flex.rs +++ b/tests/generated/aspect_ratio_flex_row_fill_width_flex.rs @@ -3,37 +3,33 @@ fn aspect_ratio_flex_row_fill_width_flex() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_row_stretch_fill_height.rs b/tests/generated/aspect_ratio_flex_row_stretch_fill_height.rs index a8a30cfee..a0490be1a 100644 --- a/tests/generated/aspect_ratio_flex_row_stretch_fill_height.rs +++ b/tests/generated/aspect_ratio_flex_row_stretch_fill_height.rs @@ -3,36 +3,32 @@ fn aspect_ratio_flex_row_stretch_fill_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_row_stretch_fill_max_height.rs b/tests/generated/aspect_ratio_flex_row_stretch_fill_max_height.rs index 6114dfe4a..fc29fb820 100644 --- a/tests/generated/aspect_ratio_flex_row_stretch_fill_max_height.rs +++ b/tests/generated/aspect_ratio_flex_row_stretch_fill_max_height.rs @@ -3,30 +3,28 @@ fn aspect_ratio_flex_row_stretch_fill_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ; - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) ; + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_row_stretch_fill_max_width.rs b/tests/generated/aspect_ratio_flex_row_stretch_fill_max_width.rs index 76b8be5ff..ab4647234 100644 --- a/tests/generated/aspect_ratio_flex_row_stretch_fill_max_width.rs +++ b/tests/generated/aspect_ratio_flex_row_stretch_fill_max_width.rs @@ -3,48 +3,44 @@ fn aspect_ratio_flex_row_stretch_fill_max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - aspect_ratio: Some(2f32), - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - Some(2f32), - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/aspect_ratio_flex_row_stretch_fill_width.rs b/tests/generated/aspect_ratio_flex_row_stretch_fill_width.rs index 71c1db69f..4a3466ef5 100644 --- a/tests/generated/aspect_ratio_flex_row_stretch_fill_width.rs +++ b/tests/generated/aspect_ratio_flex_row_stretch_fill_width.rs @@ -3,36 +3,32 @@ fn aspect_ratio_flex_row_stretch_fill_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/bevy_issue_7976_3_level.rs b/tests/generated/bevy_issue_7976_3_level.rs index 217d36066..a57756197 100644 --- a/tests/generated/bevy_issue_7976_3_level.rs +++ b/tests/generated/bevy_issue_7976_3_level.rs @@ -3,11 +3,30 @@ fn bevy_issue_7976_3_level() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Percent(1f32), + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Percent(1f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(5f32), + right: taffy::style::LengthPercentage::Length(5f32), + top: taffy::style::LengthPercentage::Length(5f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(40f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Length(5f32), @@ -16,60 +35,35 @@ fn bevy_issue_7976_3_level() { bottom: taffy::style::LengthPercentage::Length(5f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(40f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(5f32), - right: taffy::style::LengthPercentage::Length(5f32), - top: taffy::style::LengthPercentage::Length(5f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_content: Some(taffy::style::AlignContent::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 190f32, "height of node {:?}. Expected {}. Actual {}", node0, 190f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node00, 30f32, size.width); assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node00, 180f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); diff --git a/tests/generated/bevy_issue_7976_4_level.rs b/tests/generated/bevy_issue_7976_4_level.rs index 5affced4d..bb2462080 100644 --- a/tests/generated/bevy_issue_7976_4_level.rs +++ b/tests/generated/bevy_issue_7976_4_level.rs @@ -3,82 +3,76 @@ fn bevy_issue_7976_4_level() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Percent(1f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(5f32), - right: taffy::style::LengthPercentage::Length(5f32), - top: taffy::style::LengthPercentage::Length(5f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node00 = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Percent(1f32), }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(40f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(5f32), - right: taffy::style::LengthPercentage::Length(5f32), - top: taffy::style::LengthPercentage::Length(5f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(5f32), + right: taffy::style::LengthPercentage::Length(5f32), + top: taffy::style::LengthPercentage::Length(5f32), + bottom: taffy::style::LengthPercentage::Length(5f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_content: Some(taffy::style::AlignContent::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(40f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(5f32), + right: taffy::style::LengthPercentage::Length(5f32), + top: taffy::style::LengthPercentage::Length(5f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), + }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 190f32, "height of node {:?}. Expected {}. Actual {}", node0, 190f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node00, 30f32, size.width); assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node00, 180f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); assert_eq!(size.height, 170f32, "height of node {:?}. Expected {}. Actual {}", node000, 170f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node000, 5f32, location.x); diff --git a/tests/generated/bevy_issue_7976_reduced.rs b/tests/generated/bevy_issue_7976_reduced.rs index 7b24108e1..a9808ff11 100644 --- a/tests/generated/bevy_issue_7976_reduced.rs +++ b/tests/generated/bevy_issue_7976_reduced.rs @@ -3,32 +3,28 @@ fn bevy_issue_7976_reduced() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Start), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_content: Some(taffy::style::AlignContent::Start), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/bevy_issue_8017.rs b/tests/generated/bevy_issue_8017.rs index 641b73f63..6870751b2 100644 --- a/tests/generated/bevy_issue_8017.rs +++ b/tests/generated/bevy_issue_8017.rs @@ -3,135 +3,121 @@ fn bevy_issue_8017() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Percent(1f32), + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Percent(1f32), + }, + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Percent(1f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(8f32), + height: taffy::style::LengthPercentage::Length(8f32), }, - ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Percent(0.5f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(8f32), - height: taffy::style::LengthPercentage::Length(8f32), - }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Percent(0.5f32), - }, - ..Default::default() + }, + &[node00, node01], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Percent(1f32), + }, + ..Default::default() + }); + let node11 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Percent(1f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(8f32), + height: taffy::style::LengthPercentage::Length(8f32), }, - &[node00, node01], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Percent(0.5f32), }, ..Default::default() - }) - .unwrap(); - let node11 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Percent(1f32), + }, + &[node10, node11], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(8f32), + height: taffy::style::LengthPercentage::Length(8f32), }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(8f32), - height: taffy::style::LengthPercentage::Length(8f32), - }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Percent(0.5f32), - }, - ..Default::default() + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(400f32), }, - &[node10, node11], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(8f32), - height: taffy::style::LengthPercentage::Length(8f32), - }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(400f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(8f32), - top: taffy::style::LengthPercentage::Length(8f32), - bottom: taffy::style::LengthPercentage::Length(8f32), - }, - ..Default::default() + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(8f32), + top: taffy::style::LengthPercentage::Length(8f32), + bottom: taffy::style::LengthPercentage::Length(8f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 384f32, "width of node {:?}. Expected {}. Actual {}", node0, 384f32, size.width); assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node0, 188f32, size.height); assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 188f32, "width of node {:?}. Expected {}. Actual {}", node00, 188f32, size.width); assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node00, 188f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 188f32, "width of node {:?}. Expected {}. Actual {}", node01, 188f32, size.width); assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node01, 188f32, size.height); assert_eq!(location.x, 196f32, "x of node {:?}. Expected {}. Actual {}", node01, 196f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 384f32, "width of node {:?}. Expected {}. Actual {}", node1, 384f32, size.width); assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node1, 188f32, size.height); assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); assert_eq!(location.y, 204f32, "y of node {:?}. Expected {}. Actual {}", node1, 204f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 188f32, "width of node {:?}. Expected {}. Actual {}", node10, 188f32, size.width); assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node10, 188f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 188f32, "width of node {:?}. Expected {}. Actual {}", node11, 188f32, size.width); assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node11, 188f32, size.height); assert_eq!(location.x, 196f32, "x of node {:?}. Expected {}. Actual {}", node11, 196f32, location.x); diff --git a/tests/generated/bevy_issue_8017_reduced.rs b/tests/generated/bevy_issue_8017_reduced.rs index dea1c4e63..62f1e7503 100644 --- a/tests/generated/bevy_issue_8017_reduced.rs +++ b/tests/generated/bevy_issue_8017_reduced.rs @@ -3,68 +3,62 @@ fn bevy_issue_8017_reduced() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.5f32) }, - ..Default::default() + let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node0 = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.5f32) }, + ..Default::default() + }, + &[node00], + ); + let node10 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.5f32) }, + ..Default::default() + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(8f32), + height: taffy::style::LengthPercentage::Length(8f32), }, - &[node00], - ) - .unwrap(); - let node10 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.5f32) }, - ..Default::default() + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(400f32), }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(8f32), - height: taffy::style::LengthPercentage::Length(8f32), - }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(400f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node0, 196f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node00, 196f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node1, 196f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 204f32, "y of node {:?}. Expected {}. Actual {}", node1, 204f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); assert_eq!(size.height, 196f32, "height of node {:?}. Expected {}. Actual {}", node10, 196f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/bevy_issue_8082.rs b/tests/generated/bevy_issue_8082.rs index 7ecf4b45e..a6c4bb606 100644 --- a/tests/generated/bevy_issue_8082.rs +++ b/tests/generated/bevy_issue_8082.rs @@ -3,124 +3,112 @@ fn bevy_issue_8082() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node02 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node03 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::FlexStart), + align_content: Some(taffy::style::AlignContent::Center), + justify_content: Some(taffy::style::JustifyContent::Center), ..Default::default() - }) - .unwrap(); - let node02 = taffy - .new_leaf(taffy::style::Style { + }, + &[node00, node01, node02, node03], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Stretch), + align_content: Some(taffy::style::AlignContent::Center), + justify_content: Some(taffy::style::JustifyContent::FlexStart), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(400f32), }, ..Default::default() - }) - .unwrap(); - let node03 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: Some(taffy::style::AlignItems::FlexStart), - align_content: Some(taffy::style::AlignContent::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - ..Default::default() - }, - &[node00, node01, node02, node03], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Stretch), - align_content: Some(taffy::style::AlignContent::Center), - justify_content: Some(taffy::style::JustifyContent::FlexStart), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(400f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node0, 140f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node00, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node01, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node01, 50f32, size.height); assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node01, 110f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node01, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node02).unwrap(); + let Layout { size, location, .. } = taffy.layout(node02); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node02, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node02, 50f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node02, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node02, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node03).unwrap(); + let Layout { size, location, .. } = taffy.layout(node03); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node03, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node03, 50f32, size.height); assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node03, 110f32, location.x); diff --git a/tests/generated/bevy_issue_8082_percent.rs b/tests/generated/bevy_issue_8082_percent.rs index aec3d1107..6e8d34984 100644 --- a/tests/generated/bevy_issue_8082_percent.rs +++ b/tests/generated/bevy_issue_8082_percent.rs @@ -3,101 +3,89 @@ fn bevy_issue_8082_percent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node02 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node03 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::FlexStart), + align_content: Some(taffy::style::AlignContent::Center), + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node02 = taffy - .new_leaf(taffy::style::Style { + }, + &[node00, node01, node02, node03], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Stretch), + align_content: Some(taffy::style::AlignContent::Center), + justify_content: Some(taffy::style::JustifyContent::FlexStart), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(400f32), }, ..Default::default() - }) - .unwrap(); - let node03 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: Some(taffy::style::AlignItems::FlexStart), - align_content: Some(taffy::style::AlignContent::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, - ..Default::default() - }, - &[node00, node01, node02, node03], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Stretch), - align_content: Some(taffy::style::AlignContent::Center), - justify_content: Some(taffy::style::JustifyContent::FlexStart), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(400f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node01, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node01, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node02).unwrap(); + let Layout { size, location, .. } = taffy.layout(node02); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node02, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node02, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node02, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node03).unwrap(); + let Layout { size, location, .. } = taffy.layout(node03); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node03, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node03, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node03, 50f32, location.x); diff --git a/tests/generated/block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs b/tests/generated/block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs index c37bbc88a..f0724c6d5 100644 --- a/tests/generated/block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs +++ b/tests/generated/block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs @@ -3,42 +3,38 @@ fn block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: taffy::style::LengthPercentageAuto::Percent(0.05f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node0, 360f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); diff --git a/tests/generated/block_absolute_aspect_ratio_fill_height.rs b/tests/generated/block_absolute_aspect_ratio_fill_height.rs index a3eed0050..79c0242ef 100644 --- a/tests/generated/block_absolute_aspect_ratio_fill_height.rs +++ b/tests/generated/block_absolute_aspect_ratio_fill_height.rs @@ -3,43 +3,39 @@ fn block_absolute_aspect_ratio_fill_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); diff --git a/tests/generated/block_absolute_aspect_ratio_fill_height_from_inset.rs b/tests/generated/block_absolute_aspect_ratio_fill_height_from_inset.rs index 220bb8be3..4f91a3436 100644 --- a/tests/generated/block_absolute_aspect_ratio_fill_height_from_inset.rs +++ b/tests/generated/block_absolute_aspect_ratio_fill_height_from_inset.rs @@ -3,42 +3,38 @@ fn block_absolute_aspect_ratio_fill_height_from_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.1f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0, 107f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); diff --git a/tests/generated/block_absolute_aspect_ratio_fill_max_height.rs b/tests/generated/block_absolute_aspect_ratio_fill_max_height.rs index bdfd2a502..6f67ce0a8 100644 --- a/tests/generated/block_absolute_aspect_ratio_fill_max_height.rs +++ b/tests/generated/block_absolute_aspect_ratio_fill_max_height.rs @@ -3,30 +3,46 @@ fn block_absolute_aspect_ratio_fill_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { position : taffy :: style :: Position :: Absolute , max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Length (50f32) , height : auto () , } , aspect_ratio : Some (3f32) , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (3f32)) }) ,) . unwrap () ; - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + position: taffy::style::Position::Absolute, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + aspect_ratio: Some(3f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = + "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(3f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0, 17f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_aspect_ratio_fill_max_width.rs b/tests/generated/block_absolute_aspect_ratio_fill_max_width.rs index e616b4c18..3434da6a4 100644 --- a/tests/generated/block_absolute_aspect_ratio_fill_max_width.rs +++ b/tests/generated/block_absolute_aspect_ratio_fill_max_width.rs @@ -3,30 +3,46 @@ fn block_absolute_aspect_ratio_fill_max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { position : taffy :: style :: Position :: Absolute , max_size : taffy :: geometry :: Size { width : auto () , height : taffy :: style :: Dimension :: Length (50f32) , } , aspect_ratio : Some (0.5f32) , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (0.5f32)) }) ,) . unwrap () ; - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + position: taffy::style::Position::Absolute, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + aspect_ratio: Some(0.5f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = + "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(0.5f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node0, 25f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_aspect_ratio_fill_min_height.rs b/tests/generated/block_absolute_aspect_ratio_fill_min_height.rs index 7fdc0f3e4..289fe876d 100644 --- a/tests/generated/block_absolute_aspect_ratio_fill_min_height.rs +++ b/tests/generated/block_absolute_aspect_ratio_fill_min_height.rs @@ -3,37 +3,33 @@ fn block_absolute_aspect_ratio_fill_min_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - aspect_ratio: Some(3f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + aspect_ratio: Some(3f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0, 17f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_aspect_ratio_fill_min_width.rs b/tests/generated/block_absolute_aspect_ratio_fill_min_width.rs index 7854bbf11..65e99efc9 100644 --- a/tests/generated/block_absolute_aspect_ratio_fill_min_width.rs +++ b/tests/generated/block_absolute_aspect_ratio_fill_min_width.rs @@ -3,37 +3,33 @@ fn block_absolute_aspect_ratio_fill_min_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - aspect_ratio: Some(0.5f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + aspect_ratio: Some(0.5f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node0, 25f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_aspect_ratio_fill_width.rs b/tests/generated/block_absolute_aspect_ratio_fill_width.rs index b95046a36..8c9f72ba5 100644 --- a/tests/generated/block_absolute_aspect_ratio_fill_width.rs +++ b/tests/generated/block_absolute_aspect_ratio_fill_width.rs @@ -3,43 +3,39 @@ fn block_absolute_aspect_ratio_fill_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) }, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); diff --git a/tests/generated/block_absolute_aspect_ratio_fill_width_from_inset.rs b/tests/generated/block_absolute_aspect_ratio_fill_width_from_inset.rs index 3cbc79bd8..47585834b 100644 --- a/tests/generated/block_absolute_aspect_ratio_fill_width_from_inset.rs +++ b/tests/generated/block_absolute_aspect_ratio_fill_width_from_inset.rs @@ -3,42 +3,38 @@ fn block_absolute_aspect_ratio_fill_width_from_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.3f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.3f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_aspect_ratio_height_overrides_inset.rs b/tests/generated/block_absolute_aspect_ratio_height_overrides_inset.rs index 3985d865f..0b17499b3 100644 --- a/tests/generated/block_absolute_aspect_ratio_height_overrides_inset.rs +++ b/tests/generated/block_absolute_aspect_ratio_height_overrides_inset.rs @@ -3,43 +3,39 @@ fn block_absolute_aspect_ratio_height_overrides_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.1f32) }, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.3f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.1f32) }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.3f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node0, 90f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_aspect_ratio_width_overrides_inset.rs b/tests/generated/block_absolute_aspect_ratio_width_overrides_inset.rs index 238d8eec7..6d8d2ac68 100644 --- a/tests/generated/block_absolute_aspect_ratio_width_overrides_inset.rs +++ b/tests/generated/block_absolute_aspect_ratio_width_overrides_inset.rs @@ -3,43 +3,39 @@ fn block_absolute_aspect_ratio_width_overrides_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.4f32), height: auto() }, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.1f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.4f32), height: auto() }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); assert_eq!(size.height, 53f32, "height of node {:?}. Expected {}. Actual {}", node0, 53f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); diff --git a/tests/generated/block_absolute_child_with_margin_x.rs b/tests/generated/block_absolute_child_with_margin_x.rs index d36d0604f..98168d6d8 100644 --- a/tests/generated/block_absolute_child_with_margin_x.rs +++ b/tests/generated/block_absolute_child_with_margin_x.rs @@ -3,87 +3,79 @@ fn block_absolute_child_with_margin_x() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(9f32), + height: taffy::style::Dimension::Length(9f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(7f32), + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(9f32), + height: taffy::style::Dimension::Length(9f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Length(7f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(9f32), + height: taffy::style::Dimension::Length(9f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(9f32), - height: taffy::style::Dimension::Length(9f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(7f32), - right: zero(), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(9f32), - height: taffy::style::Dimension::Length(9f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Length(7f32), - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(37f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(9f32), - height: taffy::style::Dimension::Length(9f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(37f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 37f32, "height of node {:?}. Expected {}. Actual {}", node, 37f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node0, 9f32, size.width); assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node0, 9f32, size.height); assert_eq!(location.x, 7f32, "x of node {:?}. Expected {}. Actual {}", node0, 7f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node1, 9f32, size.width); assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node1, 9f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node2, 9f32, size.width); assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node2, 9f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node2, 10f32, location.x); diff --git a/tests/generated/block_absolute_child_with_margin_y.rs b/tests/generated/block_absolute_child_with_margin_y.rs index 1335e48df..39c998b30 100644 --- a/tests/generated/block_absolute_child_with_margin_y.rs +++ b/tests/generated/block_absolute_child_with_margin_y.rs @@ -3,87 +3,79 @@ fn block_absolute_child_with_margin_y() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(9f32), + height: taffy::style::Dimension::Length(9f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(7f32), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(9f32), + height: taffy::style::Dimension::Length(9f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(7f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(9f32), + height: taffy::style::Dimension::Length(9f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(9f32), - height: taffy::style::Dimension::Length(9f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(7f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(9f32), - height: taffy::style::Dimension::Length(9f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(7f32), + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(37f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(9f32), - height: taffy::style::Dimension::Length(9f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(37f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 37f32, "height of node {:?}. Expected {}. Actual {}", node, 37f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node0, 9f32, size.width); assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node0, 9f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 7f32, "y of node {:?}. Expected {}. Actual {}", node0, 7f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node1, 9f32, size.width); assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node1, 9f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node2, 9f32, size.width); assert_eq!(size.height, 9f32, "height of node {:?}. Expected {}. Actual {}", node2, 9f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_absolute_child_with_max_height.rs b/tests/generated/block_absolute_child_with_max_height.rs index 142f4215b..47e1ab891 100644 --- a/tests/generated/block_absolute_child_with_max_height.rs +++ b/tests/generated/block_absolute_child_with_max_height.rs @@ -3,61 +3,55 @@ fn block_absolute_child_with_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(150f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(20f32), + }, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(20f32), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node00, 150f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/block_absolute_layout_child_order.rs b/tests/generated/block_absolute_layout_child_order.rs index c5911f984..f8132c5b8 100644 --- a/tests/generated/block_absolute_layout_child_order.rs +++ b/tests/generated/block_absolute_layout_child_order.rs @@ -3,72 +3,64 @@ fn block_absolute_layout_child_order() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), + width: taffy::style::Dimension::Length(110f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(110f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node2, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_absolute_layout_no_size.rs b/tests/generated/block_absolute_layout_no_size.rs index cdd22b481..e998fdf1a 100644 --- a/tests/generated/block_absolute_layout_no_size.rs +++ b/tests/generated/block_absolute_layout_no_size.rs @@ -3,32 +3,29 @@ fn block_absolute_layout_no_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = + taffy.new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_layout_percentage_bottom_based_on_parent_height.rs b/tests/generated/block_absolute_layout_percentage_bottom_based_on_parent_height.rs index 22b5394c4..34764cb37 100644 --- a/tests/generated/block_absolute_layout_percentage_bottom_based_on_parent_height.rs +++ b/tests/generated/block_absolute_layout_percentage_bottom_based_on_parent_height.rs @@ -3,87 +3,79 @@ fn block_absolute_layout_percentage_bottom_based_on_parent_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.5f32), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.5f32), - bottom: auto(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node1, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node2, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_absolute_layout_percentage_height.rs b/tests/generated/block_absolute_layout_percentage_height.rs index 5f143acce..09dad5a59 100644 --- a/tests/generated/block_absolute_layout_percentage_height.rs +++ b/tests/generated/block_absolute_layout_percentage_height.rs @@ -3,45 +3,41 @@ fn block_absolute_layout_percentage_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Percent(0.5f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Percent(0.5f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: auto(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/block_absolute_layout_row_width_height_end_bottom.rs b/tests/generated/block_absolute_layout_row_width_height_end_bottom.rs index 0638686c0..f4f76f609 100644 --- a/tests/generated/block_absolute_layout_row_width_height_end_bottom.rs +++ b/tests/generated/block_absolute_layout_row_width_height_end_bottom.rs @@ -3,45 +3,41 @@ fn block_absolute_layout_row_width_height_end_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); diff --git a/tests/generated/block_absolute_layout_start_top_end_bottom.rs b/tests/generated/block_absolute_layout_start_top_end_bottom.rs index 5a59113fc..836c7a91c 100644 --- a/tests/generated/block_absolute_layout_start_top_end_bottom.rs +++ b/tests/generated/block_absolute_layout_start_top_end_bottom.rs @@ -3,42 +3,38 @@ fn block_absolute_layout_start_top_end_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/block_absolute_layout_width_height_end_bottom.rs b/tests/generated/block_absolute_layout_width_height_end_bottom.rs index 4de4f947f..fe666b01d 100644 --- a/tests/generated/block_absolute_layout_width_height_end_bottom.rs +++ b/tests/generated/block_absolute_layout_width_height_end_bottom.rs @@ -3,46 +3,42 @@ fn block_absolute_layout_width_height_end_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); diff --git a/tests/generated/block_absolute_layout_width_height_start_top.rs b/tests/generated/block_absolute_layout_width_height_start_top.rs index e55740f7c..0a9e450ca 100644 --- a/tests/generated/block_absolute_layout_width_height_start_top.rs +++ b/tests/generated/block_absolute_layout_width_height_start_top.rs @@ -3,46 +3,42 @@ fn block_absolute_layout_width_height_start_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: auto(), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/block_absolute_layout_width_height_start_top_end_bottom.rs b/tests/generated/block_absolute_layout_width_height_start_top_end_bottom.rs index aee1745d3..2598d3d56 100644 --- a/tests/generated/block_absolute_layout_width_height_start_top_end_bottom.rs +++ b/tests/generated/block_absolute_layout_width_height_start_top_end_bottom.rs @@ -3,46 +3,42 @@ fn block_absolute_layout_width_height_start_top_end_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/block_absolute_layout_within_border.rs b/tests/generated/block_absolute_layout_within_border.rs index c673cc758..a673ec10d 100644 --- a/tests/generated/block_absolute_layout_within_border.rs +++ b/tests/generated/block_absolute_layout_within_border.rs @@ -3,136 +3,126 @@ fn block_absolute_layout_within_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: auto(), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: auto(), + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: auto(), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_bottom_and_top_with_inset.rs b/tests/generated/block_absolute_margin_auto_bottom_and_top_with_inset.rs index 7c50eae88..f14a0676e 100644 --- a/tests/generated/block_absolute_margin_auto_bottom_and_top_with_inset.rs +++ b/tests/generated/block_absolute_margin_auto_bottom_and_top_with_inset.rs @@ -3,51 +3,47 @@ fn block_absolute_margin_auto_bottom_and_top_with_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(20f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_bottom_and_top_without_inset.rs b/tests/generated/block_absolute_margin_auto_bottom_and_top_without_inset.rs index 0a7fb19da..9b428a79d 100644 --- a/tests/generated/block_absolute_margin_auto_bottom_and_top_without_inset.rs +++ b/tests/generated/block_absolute_margin_auto_bottom_and_top_without_inset.rs @@ -3,45 +3,41 @@ fn block_absolute_margin_auto_bottom_and_top_without_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_bottom_with_inset.rs b/tests/generated/block_absolute_margin_auto_bottom_with_inset.rs index 14e22f8fc..091a3bfa4 100644 --- a/tests/generated/block_absolute_margin_auto_bottom_with_inset.rs +++ b/tests/generated/block_absolute_margin_auto_bottom_with_inset.rs @@ -3,52 +3,48 @@ fn block_absolute_margin_auto_bottom_with_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Auto, - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(20f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_bottom_without_inset.rs b/tests/generated/block_absolute_margin_auto_bottom_without_inset.rs index ad1df5680..8168783a6 100644 --- a/tests/generated/block_absolute_margin_auto_bottom_without_inset.rs +++ b/tests/generated/block_absolute_margin_auto_bottom_without_inset.rs @@ -3,46 +3,42 @@ fn block_absolute_margin_auto_bottom_without_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Auto, + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_left_and_right_with_inset.rs b/tests/generated/block_absolute_margin_auto_left_and_right_with_inset.rs index 273b0a825..655b8524b 100644 --- a/tests/generated/block_absolute_margin_auto_left_and_right_with_inset.rs +++ b/tests/generated/block_absolute_margin_auto_left_and_right_with_inset.rs @@ -3,51 +3,47 @@ fn block_absolute_margin_auto_left_and_right_with_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(20f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(20f32), - top: auto(), - bottom: auto(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node0, 70f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_left_and_right_without_inset.rs b/tests/generated/block_absolute_margin_auto_left_and_right_without_inset.rs index 9c0853223..964831514 100644 --- a/tests/generated/block_absolute_margin_auto_left_and_right_without_inset.rs +++ b/tests/generated/block_absolute_margin_auto_left_and_right_without_inset.rs @@ -3,45 +3,41 @@ fn block_absolute_margin_auto_left_and_right_without_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_left_child_bigger_than_parent_with_inset.rs b/tests/generated/block_absolute_margin_auto_left_child_bigger_than_parent_with_inset.rs index 73b49dab4..fa7670d8d 100644 --- a/tests/generated/block_absolute_margin_auto_left_child_bigger_than_parent_with_inset.rs +++ b/tests/generated/block_absolute_margin_auto_left_child_bigger_than_parent_with_inset.rs @@ -3,51 +3,47 @@ fn block_absolute_margin_auto_left_child_bigger_than_parent_with_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(72f32), + height: taffy::style::Dimension::Length(72f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(20f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(72f32), - height: taffy::style::Dimension::Length(72f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: zero(), - top: zero(), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(20f32), - top: auto(), - bottom: auto(), + width: taffy::style::Dimension::Length(52f32), + height: taffy::style::Dimension::Length(52f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(52f32), - height: taffy::style::Dimension::Length(52f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); assert_eq!(location.x, -40f32, "x of node {:?}. Expected {}. Actual {}", node0, -40f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_left_child_bigger_than_parent_without_inset.rs b/tests/generated/block_absolute_margin_auto_left_child_bigger_than_parent_without_inset.rs index 9b7a5acbd..02073186b 100644 --- a/tests/generated/block_absolute_margin_auto_left_child_bigger_than_parent_without_inset.rs +++ b/tests/generated/block_absolute_margin_auto_left_child_bigger_than_parent_without_inset.rs @@ -3,45 +3,41 @@ fn block_absolute_margin_auto_left_child_bigger_than_parent_without_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(72f32), + height: taffy::style::Dimension::Length(72f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(72f32), - height: taffy::style::Dimension::Length(72f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: zero(), - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(52f32), + height: taffy::style::Dimension::Length(52f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(52f32), - height: taffy::style::Dimension::Length(52f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset.rs b/tests/generated/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset.rs index 643e99dba..844ee18e1 100644 --- a/tests/generated/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset.rs +++ b/tests/generated/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset.rs @@ -3,51 +3,47 @@ fn block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(72f32), + height: taffy::style::Dimension::Length(72f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: zero(), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(20f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(72f32), - height: taffy::style::Dimension::Length(72f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: zero(), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(20f32), - top: auto(), - bottom: auto(), + width: taffy::style::Dimension::Length(52f32), + height: taffy::style::Dimension::Length(52f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(52f32), - height: taffy::style::Dimension::Length(52f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); assert_eq!(location.x, -50f32, "x of node {:?}. Expected {}. Actual {}", node0, -50f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_inset.rs b/tests/generated/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_inset.rs index a9bc7015a..eb640116c 100644 --- a/tests/generated/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_inset.rs +++ b/tests/generated/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_inset.rs @@ -3,45 +3,41 @@ fn block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_in #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(72f32), + height: taffy::style::Dimension::Length(72f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(72f32), - height: taffy::style::Dimension::Length(72f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(52f32), + height: taffy::style::Dimension::Length(52f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(52f32), - height: taffy::style::Dimension::Length(52f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset.rs b/tests/generated/block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset.rs index b727a997d..caa3543cb 100644 --- a/tests/generated/block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset.rs +++ b/tests/generated/block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset.rs @@ -3,51 +3,47 @@ fn block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(72f32), + height: taffy::style::Dimension::Length(72f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(20f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(72f32), - height: taffy::style::Dimension::Length(72f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(20f32), - top: auto(), - bottom: auto(), + width: taffy::style::Dimension::Length(52f32), + height: taffy::style::Dimension::Length(52f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(52f32), - height: taffy::style::Dimension::Length(52f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset.rs b/tests/generated/block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset.rs index f514561fa..f3f5f0505 100644 --- a/tests/generated/block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset.rs +++ b/tests/generated/block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset.rs @@ -3,45 +3,41 @@ fn block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset( #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(72f32), + height: taffy::style::Dimension::Length(72f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(72f32), - height: taffy::style::Dimension::Length(72f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(52f32), + height: taffy::style::Dimension::Length(52f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(52f32), - height: taffy::style::Dimension::Length(52f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_left_with_inset.rs b/tests/generated/block_absolute_margin_auto_left_with_inset.rs index 904359fad..7b3e0027f 100644 --- a/tests/generated/block_absolute_margin_auto_left_with_inset.rs +++ b/tests/generated/block_absolute_margin_auto_left_with_inset.rs @@ -3,51 +3,47 @@ fn block_absolute_margin_auto_left_with_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(20f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: zero(), - top: zero(), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(20f32), - top: auto(), - bottom: auto(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 130f32, "x of node {:?}. Expected {}. Actual {}", node0, 130f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_left_without_inset.rs b/tests/generated/block_absolute_margin_auto_left_without_inset.rs index 31f34b4bf..332e60694 100644 --- a/tests/generated/block_absolute_margin_auto_left_without_inset.rs +++ b/tests/generated/block_absolute_margin_auto_left_without_inset.rs @@ -3,45 +3,41 @@ fn block_absolute_margin_auto_left_without_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: zero(), - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_mutiple_children_with_inset.rs b/tests/generated/block_absolute_margin_auto_mutiple_children_with_inset.rs index aa6ebbfef..ee413464e 100644 --- a/tests/generated/block_absolute_margin_auto_mutiple_children_with_inset.rs +++ b/tests/generated/block_absolute_margin_auto_mutiple_children_with_inset.rs @@ -3,79 +3,73 @@ fn block_absolute_margin_auto_mutiple_children_with_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(20f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(20f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(20f32), - top: auto(), - bottom: auto(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(20f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: auto(), - bottom: auto(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_mutiple_children_without_inset.rs b/tests/generated/block_absolute_margin_auto_mutiple_children_without_inset.rs index 58767e1dc..5950d6b02 100644 --- a/tests/generated/block_absolute_margin_auto_mutiple_children_without_inset.rs +++ b/tests/generated/block_absolute_margin_auto_mutiple_children_without_inset.rs @@ -3,67 +3,61 @@ fn block_absolute_margin_auto_mutiple_children_without_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_right_with_inset.rs b/tests/generated/block_absolute_margin_auto_right_with_inset.rs index 920946a8e..e2d03a33c 100644 --- a/tests/generated/block_absolute_margin_auto_right_with_inset.rs +++ b/tests/generated/block_absolute_margin_auto_right_with_inset.rs @@ -3,52 +3,48 @@ fn block_absolute_margin_auto_right_with_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(20f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(20f32), - top: auto(), - bottom: auto(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_right_without_inset.rs b/tests/generated/block_absolute_margin_auto_right_without_inset.rs index b673f88f3..ce87d078c 100644 --- a/tests/generated/block_absolute_margin_auto_right_without_inset.rs +++ b/tests/generated/block_absolute_margin_auto_right_without_inset.rs @@ -3,46 +3,42 @@ fn block_absolute_margin_auto_right_without_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_top_with_inset.rs b/tests/generated/block_absolute_margin_auto_top_with_inset.rs index 2158dde4e..82b08331d 100644 --- a/tests/generated/block_absolute_margin_auto_top_with_inset.rs +++ b/tests/generated/block_absolute_margin_auto_top_with_inset.rs @@ -3,52 +3,48 @@ fn block_absolute_margin_auto_top_with_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(20f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(20f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_margin_auto_top_without_inset.rs b/tests/generated/block_absolute_margin_auto_top_without_inset.rs index 7860fa9a7..3b27bd6cb 100644 --- a/tests/generated/block_absolute_margin_auto_top_without_inset.rs +++ b/tests/generated/block_absolute_margin_auto_top_without_inset.rs @@ -3,46 +3,42 @@ fn block_absolute_margin_auto_top_without_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_margin_bottom_left_with_inset.rs b/tests/generated/block_absolute_margin_bottom_left_with_inset.rs index bc959d7e8..b8963fc96 100644 --- a/tests/generated/block_absolute_margin_bottom_left_with_inset.rs +++ b/tests/generated/block_absolute_margin_bottom_left_with_inset.rs @@ -3,52 +3,48 @@ fn block_absolute_margin_bottom_left_with_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(20f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(20f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node0, 30f32, location.x); diff --git a/tests/generated/block_absolute_margin_bottom_left_without_inset.rs b/tests/generated/block_absolute_margin_bottom_left_without_inset.rs index a84e74f53..7e38bdf3b 100644 --- a/tests/generated/block_absolute_margin_bottom_left_without_inset.rs +++ b/tests/generated/block_absolute_margin_bottom_left_without_inset.rs @@ -3,46 +3,42 @@ fn block_absolute_margin_bottom_left_without_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/block_absolute_minmax_bottom_right_max.rs b/tests/generated/block_absolute_minmax_bottom_right_max.rs index 45969feff..1ae644557 100644 --- a/tests/generated/block_absolute_minmax_bottom_right_max.rs +++ b/tests/generated/block_absolute_minmax_bottom_right_max.rs @@ -3,50 +3,46 @@ fn block_absolute_minmax_bottom_right_max() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(30f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: taffy::style::Dimension::Length(100f32), }, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(30f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); diff --git a/tests/generated/block_absolute_minmax_bottom_right_min_max.rs b/tests/generated/block_absolute_minmax_bottom_right_min_max.rs index 50a625d5d..6771d2eff 100644 --- a/tests/generated/block_absolute_minmax_bottom_right_min_max.rs +++ b/tests/generated/block_absolute_minmax_bottom_right_min_max.rs @@ -3,50 +3,46 @@ fn block_absolute_minmax_bottom_right_min_max() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(30f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), - }, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(30f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); diff --git a/tests/generated/block_absolute_minmax_bottom_right_min_max_preferred.rs b/tests/generated/block_absolute_minmax_bottom_right_min_max_preferred.rs index 33d229e65..56cb812cf 100644 --- a/tests/generated/block_absolute_minmax_bottom_right_min_max_preferred.rs +++ b/tests/generated/block_absolute_minmax_bottom_right_min_max_preferred.rs @@ -3,54 +3,50 @@ fn block_absolute_minmax_bottom_right_min_max_preferred() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), + }, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(30f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), - }, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(30f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); diff --git a/tests/generated/block_absolute_minmax_top_left_bottom_right_max.rs b/tests/generated/block_absolute_minmax_top_left_bottom_right_max.rs index 7ce62f469..35c2a6b8f 100644 --- a/tests/generated/block_absolute_minmax_top_left_bottom_right_max.rs +++ b/tests/generated/block_absolute_minmax_top_left_bottom_right_max.rs @@ -3,46 +3,42 @@ fn block_absolute_minmax_top_left_bottom_right_max() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(30f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(30f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/block_absolute_minmax_top_left_bottom_right_min_max.rs b/tests/generated/block_absolute_minmax_top_left_bottom_right_min_max.rs index e9e9e9c04..2d7201c7e 100644 --- a/tests/generated/block_absolute_minmax_top_left_bottom_right_min_max.rs +++ b/tests/generated/block_absolute_minmax_top_left_bottom_right_min_max.rs @@ -3,50 +3,46 @@ fn block_absolute_minmax_top_left_bottom_right_min_max() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(30f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), - }, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(30f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/block_absolute_no_styles.rs b/tests/generated/block_absolute_no_styles.rs index 2478f4bef..0819ab012 100644 --- a/tests/generated/block_absolute_no_styles.rs +++ b/tests/generated/block_absolute_no_styles.rs @@ -3,44 +3,38 @@ fn block_absolute_no_styles() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_absolute_padding_border_overrides_max_size.rs b/tests/generated/block_absolute_padding_border_overrides_max_size.rs index bd8dcf31f..7a5f8b94c 100644 --- a/tests/generated/block_absolute_padding_border_overrides_max_size.rs +++ b/tests/generated/block_absolute_padding_border_overrides_max_size.rs @@ -3,45 +3,41 @@ fn block_absolute_padding_border_overrides_max_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_absolute_padding_border_overrides_size.rs b/tests/generated/block_absolute_padding_border_overrides_size.rs index 04a024586..9559bb6c9 100644 --- a/tests/generated/block_absolute_padding_border_overrides_size.rs +++ b/tests/generated/block_absolute_padding_border_overrides_size.rs @@ -3,45 +3,41 @@ fn block_absolute_padding_border_overrides_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_align_baseline_child.rs b/tests/generated/block_align_baseline_child.rs index 1b42bf131..864f09c14 100644 --- a/tests/generated/block_align_baseline_child.rs +++ b/tests/generated/block_align_baseline_child.rs @@ -3,71 +3,63 @@ fn block_align_baseline_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/block_align_baseline_child_margin.rs b/tests/generated/block_align_baseline_child_margin.rs index f1e87dd80..2c7093a34 100644 --- a/tests/generated/block_align_baseline_child_margin.rs +++ b/tests/generated/block_align_baseline_child_margin.rs @@ -3,83 +3,75 @@ fn block_align_baseline_child_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node1, 35f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); diff --git a/tests/generated/block_align_baseline_child_margin_percent.rs b/tests/generated/block_align_baseline_child_margin_percent.rs index ef8e9fb8d..a083c8201 100644 --- a/tests/generated/block_align_baseline_child_margin_percent.rs +++ b/tests/generated/block_align_baseline_child_margin_percent.rs @@ -3,84 +3,76 @@ fn block_align_baseline_child_margin_percent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.01f32), + right: taffy::style::LengthPercentageAuto::Percent(0.01f32), + top: taffy::style::LengthPercentageAuto::Percent(0.01f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.01f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: taffy::style::LengthPercentageAuto::Percent(0.05f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.01f32), - right: taffy::style::LengthPercentageAuto::Percent(0.01f32), - top: taffy::style::LengthPercentageAuto::Percent(0.01f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.01f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node1, 35f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node10, 1f32, location.x); diff --git a/tests/generated/block_align_baseline_child_padding.rs b/tests/generated/block_align_baseline_child_padding.rs index 59748057f..00c33a90c 100644 --- a/tests/generated/block_align_baseline_child_padding.rs +++ b/tests/generated/block_align_baseline_child_padding.rs @@ -3,84 +3,76 @@ fn block_align_baseline_child_padding() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), }, - ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(5f32), + right: taffy::style::LengthPercentage::Length(5f32), + top: taffy::style::LengthPercentage::Length(5f32), + bottom: taffy::style::LengthPercentage::Length(5f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(5f32), - right: taffy::style::LengthPercentage::Length(5f32), - top: taffy::style::LengthPercentage::Length(5f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(5f32), - right: taffy::style::LengthPercentage::Length(5f32), - top: taffy::style::LengthPercentage::Length(5f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(5f32), + right: taffy::style::LengthPercentage::Length(5f32), + top: taffy::style::LengthPercentage::Length(5f32), + bottom: taffy::style::LengthPercentage::Length(5f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node1, 35f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); diff --git a/tests/generated/block_align_baseline_child_top.rs b/tests/generated/block_align_baseline_child_top.rs index 287a89fc3..5f425e8e2 100644 --- a/tests/generated/block_align_baseline_child_top.rs +++ b/tests/generated/block_align_baseline_child_top.rs @@ -3,78 +3,70 @@ fn block_align_baseline_child_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: auto(), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: auto(), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/block_align_baseline_child_top2.rs b/tests/generated/block_align_baseline_child_top2.rs index dd939c46a..8a2ac38f2 100644 --- a/tests/generated/block_align_baseline_child_top2.rs +++ b/tests/generated/block_align_baseline_child_top2.rs @@ -3,78 +3,70 @@ fn block_align_baseline_child_top2() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: auto(), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: auto(), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node1, 35f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/block_align_baseline_double_nested_child.rs b/tests/generated/block_align_baseline_double_nested_child.rs index e1a883882..9c7de40fb 100644 --- a/tests/generated/block_align_baseline_double_nested_child.rs +++ b/tests/generated/block_align_baseline_double_nested_child.rs @@ -3,90 +3,80 @@ fn block_align_baseline_double_nested_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(50f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node00], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(15f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(15f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Baseline), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node10, 15f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/block_aspect_ratio_fill_height.rs b/tests/generated/block_aspect_ratio_fill_height.rs index b16fcf530..5f2ca5c3a 100644 --- a/tests/generated/block_aspect_ratio_fill_height.rs +++ b/tests/generated/block_aspect_ratio_fill_height.rs @@ -3,37 +3,33 @@ fn block_aspect_ratio_fill_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_aspect_ratio_fill_max_height.rs b/tests/generated/block_aspect_ratio_fill_max_height.rs index 64bfe1d71..5be5c0390 100644 --- a/tests/generated/block_aspect_ratio_fill_max_height.rs +++ b/tests/generated/block_aspect_ratio_fill_max_height.rs @@ -3,30 +3,28 @@ fn block_aspect_ratio_fill_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { display : taffy :: style :: Display :: Block , max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ; - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { display : taffy :: style :: Display :: Block , max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) ; + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_aspect_ratio_fill_max_width.rs b/tests/generated/block_aspect_ratio_fill_max_width.rs index a55ff3a83..4d686f803 100644 --- a/tests/generated/block_aspect_ratio_fill_max_width.rs +++ b/tests/generated/block_aspect_ratio_fill_max_width.rs @@ -3,49 +3,45 @@ fn block_aspect_ratio_fill_max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - display: taffy::style::Display::Block, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - aspect_ratio: Some(2f32), - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + display: taffy::style::Display::Block, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - Some(2f32), - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_aspect_ratio_fill_min_height.rs b/tests/generated/block_aspect_ratio_fill_min_height.rs index d0c2cc3e3..3aea4c636 100644 --- a/tests/generated/block_aspect_ratio_fill_min_height.rs +++ b/tests/generated/block_aspect_ratio_fill_min_height.rs @@ -3,37 +3,33 @@ fn block_aspect_ratio_fill_min_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_aspect_ratio_fill_min_width.rs b/tests/generated/block_aspect_ratio_fill_min_width.rs index 7aacc4e7c..b743c7b39 100644 --- a/tests/generated/block_aspect_ratio_fill_min_width.rs +++ b/tests/generated/block_aspect_ratio_fill_min_width.rs @@ -3,49 +3,45 @@ fn block_aspect_ratio_fill_min_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - display: taffy::style::Display::Block, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, - aspect_ratio: Some(2f32), - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + display: taffy::style::Display::Block, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "\n \n "; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "\n \n "; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - Some(2f32), - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_aspect_ratio_fill_width.rs b/tests/generated/block_aspect_ratio_fill_width.rs index a8244c1e1..2073b1ca0 100644 --- a/tests/generated/block_aspect_ratio_fill_width.rs +++ b/tests/generated/block_aspect_ratio_fill_width.rs @@ -3,37 +3,33 @@ fn block_aspect_ratio_fill_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(40f32) }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_basic.rs b/tests/generated/block_basic.rs index b7a9f22a9..287d6b2c5 100644 --- a/tests/generated/block_basic.rs +++ b/tests/generated/block_basic.rs @@ -3,43 +3,37 @@ fn block_basic() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_border_fixed_size.rs b/tests/generated/block_border_fixed_size.rs index 519f70fd6..e1faee7f3 100644 --- a/tests/generated/block_border_fixed_size.rs +++ b/tests/generated/block_border_fixed_size.rs @@ -3,52 +3,46 @@ fn block_border_fixed_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 38f32, "width of node {:?}. Expected {}. Actual {}", node0, 38f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 38f32, "width of node {:?}. Expected {}. Actual {}", node1, 38f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); diff --git a/tests/generated/block_border_intrinsic_size.rs b/tests/generated/block_border_intrinsic_size.rs index 1e3bf3dbc..3a9a4710b 100644 --- a/tests/generated/block_border_intrinsic_size.rs +++ b/tests/generated/block_border_intrinsic_size.rs @@ -3,51 +3,45 @@ fn block_border_intrinsic_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node, 62f32, size.width); assert_eq!(size.height, 28f32, "height of node {:?}. Expected {}. Actual {}", node, 28f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); diff --git a/tests/generated/block_border_percentage_fixed_size.rs b/tests/generated/block_border_percentage_fixed_size.rs index e612a0701..8d9cbfda8 100644 --- a/tests/generated/block_border_percentage_fixed_size.rs +++ b/tests/generated/block_border_percentage_fixed_size.rs @@ -3,47 +3,41 @@ fn block_border_percentage_fixed_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/block_border_percentage_intrinsic_size.rs b/tests/generated/block_border_percentage_intrinsic_size.rs index 2fc238a25..5f6822c01 100644 --- a/tests/generated/block_border_percentage_intrinsic_size.rs +++ b/tests/generated/block_border_percentage_intrinsic_size.rs @@ -3,40 +3,34 @@ fn block_border_percentage_intrinsic_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node00 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/block_display_none.rs b/tests/generated/block_display_none.rs index 1d2864acc..882641823 100644 --- a/tests/generated/block_display_none.rs +++ b/tests/generated/block_display_none.rs @@ -3,55 +3,47 @@ fn block_display_none() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::None, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_display_none_with_child.rs b/tests/generated/block_display_none_with_child.rs index 54efcada0..7203a6601 100644 --- a/tests/generated/block_display_none_with_child.rs +++ b/tests/generated/block_display_none_with_child.rs @@ -3,71 +3,61 @@ fn block_display_none_with_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }, + &[node10], + ); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }, - &[node10], - ) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_display_none_with_inset.rs b/tests/generated/block_display_none_with_inset.rs index 6ea59e911..0f5fa20a1 100644 --- a/tests/generated/block_display_none_with_inset.rs +++ b/tests/generated/block_display_none_with_inset.rs @@ -3,53 +3,47 @@ fn block_display_none_with_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::None, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_display_none_with_margin.rs b/tests/generated/block_display_none_with_margin.rs index a2d0c4191..3d2fbb31d 100644 --- a/tests/generated/block_display_none_with_margin.rs +++ b/tests/generated/block_display_none_with_margin.rs @@ -3,56 +3,50 @@ fn block_display_none_with_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::None, + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_display_none_with_position_absolute.rs b/tests/generated/block_display_none_with_position_absolute.rs index 07cd31902..ad63391fa 100644 --- a/tests/generated/block_display_none_with_position_absolute.rs +++ b/tests/generated/block_display_none_with_position_absolute.rs @@ -3,40 +3,36 @@ fn block_display_none_with_position_absolute() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::None, - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_inset_fixed.rs b/tests/generated/block_inset_fixed.rs index 191c3d697..804913059 100644 --- a/tests/generated/block_inset_fixed.rs +++ b/tests/generated/block_inset_fixed.rs @@ -3,72 +3,64 @@ fn block_inset_fixed() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(2f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(4f32), - bottom: auto(), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(2f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(4f32), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(6f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(8f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(2f32), + right: taffy::style::LengthPercentageAuto::Length(6f32), + top: taffy::style::LengthPercentageAuto::Length(4f32), + bottom: taffy::style::LengthPercentageAuto::Length(8f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(6f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(8f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(2f32), - right: taffy::style::LengthPercentageAuto::Length(6f32), - top: taffy::style::LengthPercentageAuto::Length(4f32), - bottom: taffy::style::LengthPercentageAuto::Length(8f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node0, 2f32, location.x); assert_eq!(location.y, 4f32, "y of node {:?}. Expected {}. Actual {}", node0, 4f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, -6f32, "x of node {:?}. Expected {}. Actual {}", node1, -6f32, location.x); assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node1, 2f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node2, 2f32, location.x); diff --git a/tests/generated/block_inset_percentage.rs b/tests/generated/block_inset_percentage.rs index 2f978ae3f..61f008a98 100644 --- a/tests/generated/block_inset_percentage.rs +++ b/tests/generated/block_inset_percentage.rs @@ -3,72 +3,64 @@ fn block_inset_percentage() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.02f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.04f32), - bottom: auto(), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.02f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.04f32), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Percent(0.06f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Percent(0.08f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.02f32), + right: taffy::style::LengthPercentageAuto::Percent(0.06f32), + top: taffy::style::LengthPercentageAuto::Percent(0.04f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.08f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Percent(0.06f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Percent(0.08f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.02f32), - right: taffy::style::LengthPercentageAuto::Percent(0.06f32), - top: taffy::style::LengthPercentageAuto::Percent(0.04f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.08f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node0, 1f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, -3f32, "x of node {:?}. Expected {}. Actual {}", node1, -3f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node2, 1f32, location.x); diff --git a/tests/generated/block_intrinsic_width.rs b/tests/generated/block_intrinsic_width.rs index 1e31bf910..01161c48b 100644 --- a/tests/generated/block_intrinsic_width.rs +++ b/tests/generated/block_intrinsic_width.rs @@ -3,42 +3,36 @@ fn block_intrinsic_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_auto_bottom.rs b/tests/generated/block_margin_auto_bottom.rs index 46f74b760..02e0e18b3 100644 --- a/tests/generated/block_margin_auto_bottom.rs +++ b/tests/generated/block_margin_auto_bottom.rs @@ -3,59 +3,53 @@ fn block_margin_auto_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Auto, + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_auto_bottom_and_top.rs b/tests/generated/block_margin_auto_bottom_and_top.rs index e4ac7187a..d4af8b5c3 100644 --- a/tests/generated/block_margin_auto_bottom_and_top.rs +++ b/tests/generated/block_margin_auto_bottom_and_top.rs @@ -3,58 +3,52 @@ fn block_margin_auto_bottom_and_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_auto_left.rs b/tests/generated/block_margin_auto_left.rs index 548baa611..b868bf273 100644 --- a/tests/generated/block_margin_auto_left.rs +++ b/tests/generated/block_margin_auto_left.rs @@ -3,58 +3,52 @@ fn block_margin_auto_left() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: zero(), - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node0, 150f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_auto_left_and_right.rs b/tests/generated/block_margin_auto_left_and_right.rs index f91749523..72efa54c0 100644 --- a/tests/generated/block_margin_auto_left_and_right.rs +++ b/tests/generated/block_margin_auto_left_and_right.rs @@ -3,58 +3,52 @@ fn block_margin_auto_left_and_right() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node0, 75f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_auto_left_child_bigger_than_parent.rs b/tests/generated/block_margin_auto_left_child_bigger_than_parent.rs index 254793a72..7520bc655 100644 --- a/tests/generated/block_margin_auto_left_child_bigger_than_parent.rs +++ b/tests/generated/block_margin_auto_left_child_bigger_than_parent.rs @@ -3,44 +3,40 @@ fn block_margin_auto_left_child_bigger_than_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(72f32), + height: taffy::style::Dimension::Length(72f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(72f32), - height: taffy::style::Dimension::Length(72f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: zero(), - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(52f32), + height: taffy::style::Dimension::Length(52f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(52f32), - height: taffy::style::Dimension::Length(52f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_margin_auto_left_fix_right_child_bigger_than_parent.rs b/tests/generated/block_margin_auto_left_fix_right_child_bigger_than_parent.rs index 66088eae9..1fc3ab398 100644 --- a/tests/generated/block_margin_auto_left_fix_right_child_bigger_than_parent.rs +++ b/tests/generated/block_margin_auto_left_fix_right_child_bigger_than_parent.rs @@ -3,44 +3,40 @@ fn block_margin_auto_left_fix_right_child_bigger_than_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(72f32), + height: taffy::style::Dimension::Length(72f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(72f32), - height: taffy::style::Dimension::Length(72f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(52f32), + height: taffy::style::Dimension::Length(52f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(52f32), - height: taffy::style::Dimension::Length(52f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_margin_auto_left_right_child_bigger_than_parent.rs b/tests/generated/block_margin_auto_left_right_child_bigger_than_parent.rs index 406a15f3d..94edca95f 100644 --- a/tests/generated/block_margin_auto_left_right_child_bigger_than_parent.rs +++ b/tests/generated/block_margin_auto_left_right_child_bigger_than_parent.rs @@ -3,44 +3,40 @@ fn block_margin_auto_left_right_child_bigger_than_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(72f32), + height: taffy::style::Dimension::Length(72f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(72f32), - height: taffy::style::Dimension::Length(72f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(52f32), + height: taffy::style::Dimension::Length(52f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(52f32), - height: taffy::style::Dimension::Length(52f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node0, 72f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_margin_auto_mutiple_children.rs b/tests/generated/block_margin_auto_mutiple_children.rs index 220be5332..bbc6e174c 100644 --- a/tests/generated/block_margin_auto_mutiple_children.rs +++ b/tests/generated/block_margin_auto_mutiple_children.rs @@ -3,79 +3,71 @@ fn block_margin_auto_mutiple_children() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_auto_right.rs b/tests/generated/block_margin_auto_right.rs index ba8c8eb2c..15f89ea3d 100644 --- a/tests/generated/block_margin_auto_right.rs +++ b/tests/generated/block_margin_auto_right.rs @@ -3,59 +3,53 @@ fn block_margin_auto_right() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_auto_top.rs b/tests/generated/block_margin_auto_top.rs index 4fc171b41..1bab58eb0 100644 --- a/tests/generated/block_margin_auto_top.rs +++ b/tests/generated/block_margin_auto_top.rs @@ -3,59 +3,53 @@ fn block_margin_auto_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_x_fixed_auto_bottom.rs b/tests/generated/block_margin_x_fixed_auto_bottom.rs index b64ad82c1..708b8085a 100644 --- a/tests/generated/block_margin_x_fixed_auto_bottom.rs +++ b/tests/generated/block_margin_x_fixed_auto_bottom.rs @@ -3,52 +3,46 @@ fn block_margin_x_fixed_auto_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Auto, - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_x_fixed_auto_left.rs b/tests/generated/block_margin_x_fixed_auto_left.rs index 43e7408d3..6c054a121 100644 --- a/tests/generated/block_margin_x_fixed_auto_left.rs +++ b/tests/generated/block_margin_x_fixed_auto_left.rs @@ -3,52 +3,46 @@ fn block_margin_x_fixed_auto_left() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: zero(), - top: zero(), - bottom: zero(), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node0, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_x_fixed_auto_left_and_right.rs b/tests/generated/block_margin_x_fixed_auto_left_and_right.rs index 04667c02f..00389dff1 100644 --- a/tests/generated/block_margin_x_fixed_auto_left_and_right.rs +++ b/tests/generated/block_margin_x_fixed_auto_left_and_right.rs @@ -3,52 +3,46 @@ fn block_margin_x_fixed_auto_left_and_right() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_x_fixed_auto_right.rs b/tests/generated/block_margin_x_fixed_auto_right.rs index f9681b9ee..20f04a0fd 100644 --- a/tests/generated/block_margin_x_fixed_auto_right.rs +++ b/tests/generated/block_margin_x_fixed_auto_right.rs @@ -3,52 +3,46 @@ fn block_margin_x_fixed_auto_right() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_x_fixed_auto_top.rs b/tests/generated/block_margin_x_fixed_auto_top.rs index 2d44c4491..3ecff7f1b 100644 --- a/tests/generated/block_margin_x_fixed_auto_top.rs +++ b/tests/generated/block_margin_x_fixed_auto_top.rs @@ -3,52 +3,46 @@ fn block_margin_x_fixed_auto_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: zero(), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_x_fixed_size_negative.rs b/tests/generated/block_margin_x_fixed_size_negative.rs index d56154fe8..c541b1824 100644 --- a/tests/generated/block_margin_x_fixed_size_negative.rs +++ b/tests/generated/block_margin_x_fixed_size_negative.rs @@ -3,49 +3,43 @@ fn block_margin_x_fixed_size_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(-10f32), - right: taffy::style::LengthPercentageAuto::Length(-5f32), - top: zero(), - bottom: zero(), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(-10f32), + right: taffy::style::LengthPercentageAuto::Length(-5f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 65f32, "width of node {:?}. Expected {}. Actual {}", node0, 65f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_x_fixed_size_positive.rs b/tests/generated/block_margin_x_fixed_size_positive.rs index 9d799484e..d1979aea7 100644 --- a/tests/generated/block_margin_x_fixed_size_positive.rs +++ b/tests/generated/block_margin_x_fixed_size_positive.rs @@ -3,49 +3,43 @@ fn block_margin_x_fixed_size_positive() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: zero(), - bottom: zero(), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_x_intrinsic_size_negative.rs b/tests/generated/block_margin_x_intrinsic_size_negative.rs index cb2f96dc2..bbd544bd7 100644 --- a/tests/generated/block_margin_x_intrinsic_size_negative.rs +++ b/tests/generated/block_margin_x_intrinsic_size_negative.rs @@ -3,45 +3,39 @@ fn block_margin_x_intrinsic_size_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(-10f32), - right: taffy::style::LengthPercentageAuto::Length(-5f32), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(-10f32), + right: taffy::style::LengthPercentageAuto::Length(-5f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 15f32, "width of node {:?}. Expected {}. Actual {}", node0, 15f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_x_intrinsic_size_positive.rs b/tests/generated/block_margin_x_intrinsic_size_positive.rs index 455a72281..9fb155b16 100644 --- a/tests/generated/block_margin_x_intrinsic_size_positive.rs +++ b/tests/generated/block_margin_x_intrinsic_size_positive.rs @@ -3,45 +3,39 @@ fn block_margin_x_intrinsic_size_positive() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 15f32, "width of node {:?}. Expected {}. Actual {}", node, 15f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 15f32, "width of node {:?}. Expected {}. Actual {}", node1, 15f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_x_percentage_fixed_size_negative.rs b/tests/generated/block_margin_x_percentage_fixed_size_negative.rs index 3af4cf832..4bd8f3696 100644 --- a/tests/generated/block_margin_x_percentage_fixed_size_negative.rs +++ b/tests/generated/block_margin_x_percentage_fixed_size_negative.rs @@ -3,49 +3,43 @@ fn block_margin_x_percentage_fixed_size_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(-0.2f32), - right: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - top: zero(), - bottom: zero(), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(-0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 65f32, "width of node {:?}. Expected {}. Actual {}", node0, 65f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, -10f32, "x of node {:?}. Expected {}. Actual {}", node0, -10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_x_percentage_fixed_size_positive.rs b/tests/generated/block_margin_x_percentage_fixed_size_positive.rs index d71f418f8..3386f0a1e 100644 --- a/tests/generated/block_margin_x_percentage_fixed_size_positive.rs +++ b/tests/generated/block_margin_x_percentage_fixed_size_positive.rs @@ -3,49 +3,43 @@ fn block_margin_x_percentage_fixed_size_positive() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.2f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: zero(), - bottom: zero(), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_x_percentage_intrinsic_size_other_negative.rs b/tests/generated/block_margin_x_percentage_intrinsic_size_other_negative.rs index 263581ddc..fcd40d137 100644 --- a/tests/generated/block_margin_x_percentage_intrinsic_size_other_negative.rs +++ b/tests/generated/block_margin_x_percentage_intrinsic_size_other_negative.rs @@ -3,48 +3,42 @@ fn block_margin_x_percentage_intrinsic_size_other_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(-0.2f32), - right: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(-0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node0, 130f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node0, -20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_x_percentage_intrinsic_size_other_positive.rs b/tests/generated/block_margin_x_percentage_intrinsic_size_other_positive.rs index 20b137562..8486a02bf 100644 --- a/tests/generated/block_margin_x_percentage_intrinsic_size_other_positive.rs +++ b/tests/generated/block_margin_x_percentage_intrinsic_size_other_positive.rs @@ -3,48 +3,42 @@ fn block_margin_x_percentage_intrinsic_size_other_positive() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.2f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_x_percentage_intrinsic_size_self_negative.rs b/tests/generated/block_margin_x_percentage_intrinsic_size_self_negative.rs index 86701640e..1260f00a3 100644 --- a/tests/generated/block_margin_x_percentage_intrinsic_size_self_negative.rs +++ b/tests/generated/block_margin_x_percentage_intrinsic_size_self_negative.rs @@ -3,37 +3,33 @@ fn block_margin_x_percentage_intrinsic_size_self_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(-0.2f32), - right: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(-0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node0, -20f32, location.x); diff --git a/tests/generated/block_margin_x_percentage_intrinsic_size_self_positive.rs b/tests/generated/block_margin_x_percentage_intrinsic_size_self_positive.rs index eafa9a8d2..0a10335d9 100644 --- a/tests/generated/block_margin_x_percentage_intrinsic_size_self_positive.rs +++ b/tests/generated/block_margin_x_percentage_intrinsic_size_self_positive.rs @@ -3,37 +3,33 @@ fn block_margin_x_percentage_intrinsic_size_self_positive() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.2f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_complex.rs b/tests/generated/block_margin_y_collapse_complex.rs index 986b3225f..1e1a3e0e8 100644 --- a/tests/generated/block_margin_y_collapse_complex.rs +++ b/tests/generated/block_margin_y_collapse_complex.rs @@ -3,8 +3,48 @@ fn block_margin_y_collapse_complex() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-5f32), + bottom: taffy::style::LengthPercentageAuto::Length(-5f32), + }, + ..Default::default() + }); + let node11 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(7f32), + bottom: taffy::style::LengthPercentageAuto::Length(3f32), + }, + ..Default::default() + }); + let node12 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-6f32), + bottom: taffy::style::LengthPercentageAuto::Length(9f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -13,133 +53,77 @@ fn block_margin_y_collapse_complex() { bottom: taffy::style::LengthPercentageAuto::Length(-10f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-5f32), - bottom: taffy::style::LengthPercentageAuto::Length(-5f32), - }, - ..Default::default() - }) - .unwrap(); - let node11 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(7f32), - bottom: taffy::style::LengthPercentageAuto::Length(3f32), - }, - ..Default::default() - }) - .unwrap(); - let node12 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-6f32), - bottom: taffy::style::LengthPercentageAuto::Length(9f32), - }, + }, + &[node10, node11, node12], + ); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-5f32), + bottom: taffy::style::LengthPercentageAuto::Length(-5f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, - ..Default::default() - }, - &[node10, node11, node12], - ) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-5f32), - bottom: taffy::style::LengthPercentageAuto::Length(-5f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node1, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node10, -5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node11, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); assert_eq!(location.y, 7f32, "y of node {:?}. Expected {}. Actual {}", node11, 7f32, location.y); - let Layout { size, location, .. } = taffy.layout(node12).unwrap(); + let Layout { size, location, .. } = taffy.layout(node12); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node12, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node12, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); assert_eq!(location.y, -6f32, "y of node {:?}. Expected {}. Actual {}", node12, -6f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node2, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_blocked_by_aspect_ratio.rs b/tests/generated/block_margin_y_collapse_through_blocked_by_aspect_ratio.rs index 9b47999cf..434c03817 100644 --- a/tests/generated/block_margin_y_collapse_through_blocked_by_aspect_ratio.rs +++ b/tests/generated/block_margin_y_collapse_through_blocked_by_aspect_ratio.rs @@ -3,75 +3,67 @@ fn block_margin_y_collapse_through_blocked_by_aspect_ratio() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + aspect_ratio: Some(2f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - aspect_ratio: Some(2f32), - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 65f32, "height of node {:?}. Expected {}. Actual {}", node, 65f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_blocked_by_border_bottom.rs b/tests/generated/block_margin_y_collapse_through_blocked_by_border_bottom.rs index 10ed6d322..3ec1c5ac7 100644 --- a/tests/generated/block_margin_y_collapse_through_blocked_by_border_bottom.rs +++ b/tests/generated/block_margin_y_collapse_through_blocked_by_border_bottom.rs @@ -3,74 +3,66 @@ fn block_margin_y_collapse_through_blocked_by_border_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_blocked_by_border_top.rs b/tests/generated/block_margin_y_collapse_through_blocked_by_border_top.rs index 98874de61..752a7d41c 100644 --- a/tests/generated/block_margin_y_collapse_through_blocked_by_border_top.rs +++ b/tests/generated/block_margin_y_collapse_through_blocked_by_border_top.rs @@ -3,74 +3,66 @@ fn block_margin_y_collapse_through_blocked_by_border_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_blocked_by_height.rs b/tests/generated/block_margin_y_collapse_through_blocked_by_height.rs index 0c1add949..481f0478d 100644 --- a/tests/generated/block_margin_y_collapse_through_blocked_by_height.rs +++ b/tests/generated/block_margin_y_collapse_through_blocked_by_height.rs @@ -3,75 +3,67 @@ fn block_margin_y_collapse_through_blocked_by_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(1f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(1f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_blocked_by_line_box.rs b/tests/generated/block_margin_y_collapse_through_blocked_by_line_box.rs index 1de2168f2..ffc9a9449 100644 --- a/tests/generated/block_margin_y_collapse_through_blocked_by_line_box.rs +++ b/tests/generated/block_margin_y_collapse_through_blocked_by_line_box.rs @@ -3,86 +3,72 @@ fn block_margin_y_collapse_through_blocked_by_line_box() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), - top: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_blocked_by_line_box_with_height_zero.rs b/tests/generated/block_margin_y_collapse_through_blocked_by_line_box_with_height_zero.rs index 4e517fe12..f8a4fb982 100644 --- a/tests/generated/block_margin_y_collapse_through_blocked_by_line_box_with_height_zero.rs +++ b/tests/generated/block_margin_y_collapse_through_blocked_by_line_box_with_height_zero.rs @@ -3,87 +3,73 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_height_zero() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(0f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), - top: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(0f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero.rs b/tests/generated/block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero.rs index 7c188f615..2204bcc91 100644 --- a/tests/generated/block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero.rs +++ b/tests/generated/block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero.rs @@ -3,87 +3,73 @@ fn block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(0f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), - top: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { - display: taffy::style::Display::Block, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(0f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_blocked_by_min_height.rs b/tests/generated/block_margin_y_collapse_through_blocked_by_min_height.rs index 1bdd45d45..96ce3eebe 100644 --- a/tests/generated/block_margin_y_collapse_through_blocked_by_min_height.rs +++ b/tests/generated/block_margin_y_collapse_through_blocked_by_min_height.rs @@ -3,75 +3,67 @@ fn block_margin_y_collapse_through_blocked_by_min_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(1f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(1f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_x_hidden.rs b/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_x_hidden.rs index 34fcecdc1..3db57ddda 100644 --- a/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_x_hidden.rs +++ b/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_x_hidden.rs @@ -3,76 +3,68 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Visible }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Visible }, - scrollbar_width: 15f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_x_scroll.rs b/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_x_scroll.rs index d97f37305..19b9cac00 100644 --- a/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_x_scroll.rs +++ b/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_x_scroll.rs @@ -3,76 +3,68 @@ fn block_margin_y_collapse_through_blocked_by_overflow_x_scroll() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Visible }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Visible }, - scrollbar_width: 15f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 55f32, "height of node {:?}. Expected {}. Actual {}", node, 55f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node1, 15f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_y_hidden.rs b/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_y_hidden.rs index 8322d7ede..21ac0c3c4 100644 --- a/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_y_hidden.rs +++ b/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_y_hidden.rs @@ -3,76 +3,68 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Hidden }, - scrollbar_width: 15f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_y_scroll.rs b/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_y_scroll.rs index 1d88f18f2..aa48622e4 100644 --- a/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_y_scroll.rs +++ b/tests/generated/block_margin_y_collapse_through_blocked_by_overflow_y_scroll.rs @@ -3,76 +3,68 @@ fn block_margin_y_collapse_through_blocked_by_overflow_y_scroll() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Scroll }, - scrollbar_width: 15f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_blocked_by_padding_bottom.rs b/tests/generated/block_margin_y_collapse_through_blocked_by_padding_bottom.rs index a35d9c8a3..1e3fa8e04 100644 --- a/tests/generated/block_margin_y_collapse_through_blocked_by_padding_bottom.rs +++ b/tests/generated/block_margin_y_collapse_through_blocked_by_padding_bottom.rs @@ -3,80 +3,72 @@ fn block_margin_y_collapse_through_blocked_by_padding_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + padding: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentage::Length(1f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - padding: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentage::Length(1f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_blocked_by_padding_top.rs b/tests/generated/block_margin_y_collapse_through_blocked_by_padding_top.rs index 1dee2ba3a..340528e8b 100644 --- a/tests/generated/block_margin_y_collapse_through_blocked_by_padding_top.rs +++ b/tests/generated/block_margin_y_collapse_through_blocked_by_padding_top.rs @@ -3,80 +3,72 @@ fn block_margin_y_collapse_through_blocked_by_padding_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + padding: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: zero(), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - padding: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_negative.rs b/tests/generated/block_margin_y_collapse_through_negative.rs index 2ae637c11..c82f20399 100644 --- a/tests/generated/block_margin_y_collapse_through_negative.rs +++ b/tests/generated/block_margin_y_collapse_through_negative.rs @@ -3,74 +3,66 @@ fn block_margin_y_collapse_through_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(-5f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-7f32), + bottom: taffy::style::LengthPercentageAuto::Length(-3f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-2f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(-5f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-7f32), - bottom: taffy::style::LengthPercentageAuto::Length(-3f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-2f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 13f32, "height of node {:?}. Expected {}. Actual {}", node, 13f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node1, 3f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_positive.rs b/tests/generated/block_margin_y_collapse_through_positive.rs index 3b3456547..f7230c0b2 100644 --- a/tests/generated/block_margin_y_collapse_through_positive.rs +++ b/tests/generated/block_margin_y_collapse_through_positive.rs @@ -3,74 +3,66 @@ fn block_margin_y_collapse_through_positive() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_positive_and_negative.rs b/tests/generated/block_margin_y_collapse_through_positive_and_negative.rs index 8901443a3..5aad5e1ca 100644 --- a/tests/generated/block_margin_y_collapse_through_positive_and_negative.rs +++ b/tests/generated/block_margin_y_collapse_through_positive_and_negative.rs @@ -3,74 +3,66 @@ fn block_margin_y_collapse_through_positive_and_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(-4f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(7f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(-4f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(7f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node, 17f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_collapse_through_with_absolute_child.rs b/tests/generated/block_margin_y_collapse_through_with_absolute_child.rs index 9821746eb..622cf9616 100644 --- a/tests/generated/block_margin_y_collapse_through_with_absolute_child.rs +++ b/tests/generated/block_margin_y_collapse_through_with_absolute_child.rs @@ -3,97 +3,81 @@ fn block_margin_y_collapse_through_with_absolute_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf_with_measure( + taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, margin: taffy::geometry::Rect { left: zero(), right: zero(), - top: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf_with_measure( - taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_blocked_by_border_top.rs b/tests/generated/block_margin_y_first_child_collapse_blocked_by_border_top.rs index a7097d6ab..eba774295 100644 --- a/tests/generated/block_margin_y_first_child_collapse_blocked_by_border_top.rs +++ b/tests/generated/block_margin_y_first_child_collapse_blocked_by_border_top.rs @@ -3,72 +3,64 @@ fn block_margin_y_first_child_collapse_blocked_by_border_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden.rs b/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden.rs index 7ed957a41..2afff60be 100644 --- a/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden.rs +++ b/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden.rs @@ -3,77 +3,66 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Visible, - }, - scrollbar_width: 15f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Visible }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll.rs b/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll.rs index eb3723f67..ba144f9cd 100644 --- a/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll.rs +++ b/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll.rs @@ -3,77 +3,66 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Visible, - }, - scrollbar_width: 15f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Visible }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node, 45f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden.rs b/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden.rs index 7fe643d2a..de261c47f 100644 --- a/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden.rs +++ b/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden.rs @@ -3,77 +3,66 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Visible, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll.rs b/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll.rs index bcb497268..67921eff4 100644 --- a/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll.rs +++ b/tests/generated/block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll.rs @@ -3,77 +3,66 @@ fn block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Visible, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node00, 35f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node000, 35f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_blocked_by_padding_top.rs b/tests/generated/block_margin_y_first_child_collapse_blocked_by_padding_top.rs index 85b06ac0f..03d135f0b 100644 --- a/tests/generated/block_margin_y_first_child_collapse_blocked_by_padding_top.rs +++ b/tests/generated/block_margin_y_first_child_collapse_blocked_by_padding_top.rs @@ -3,78 +3,70 @@ fn block_margin_y_first_child_collapse_blocked_by_padding_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - padding: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: zero(), - }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + padding: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node, 31f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node0, 21f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 11f32, "y of node {:?}. Expected {}. Actual {}", node00, 11f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_negative_equal.rs b/tests/generated/block_margin_y_first_child_collapse_negative_equal.rs index 741586814..a010f0127 100644 --- a/tests/generated/block_margin_y_first_child_collapse_negative_equal.rs +++ b/tests/generated/block_margin_y_first_child_collapse_negative_equal.rs @@ -3,72 +3,64 @@ fn block_margin_y_first_child_collapse_negative_equal() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_negative_parent_larger.rs b/tests/generated/block_margin_y_first_child_collapse_negative_parent_larger.rs index 0c73943be..b21a08451 100644 --- a/tests/generated/block_margin_y_first_child_collapse_negative_parent_larger.rs +++ b/tests/generated/block_margin_y_first_child_collapse_negative_parent_larger.rs @@ -3,72 +3,64 @@ fn block_margin_y_first_child_collapse_negative_parent_larger() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-5f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-5f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_negative_parent_smaller.rs b/tests/generated/block_margin_y_first_child_collapse_negative_parent_smaller.rs index 809d54a6e..6bdb55b7e 100644 --- a/tests/generated/block_margin_y_first_child_collapse_negative_parent_smaller.rs +++ b/tests/generated/block_margin_y_first_child_collapse_negative_parent_smaller.rs @@ -3,72 +3,64 @@ fn block_margin_y_first_child_collapse_negative_parent_smaller() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-5f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-5f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_not_blocked_by_border_bottom.rs b/tests/generated/block_margin_y_first_child_collapse_not_blocked_by_border_bottom.rs index 2fff065fc..7f6f2fce5 100644 --- a/tests/generated/block_margin_y_first_child_collapse_not_blocked_by_border_bottom.rs +++ b/tests/generated/block_margin_y_first_child_collapse_not_blocked_by_border_bottom.rs @@ -3,72 +3,64 @@ fn block_margin_y_first_child_collapse_not_blocked_by_border_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_not_blocked_by_padding_bottom.rs b/tests/generated/block_margin_y_first_child_collapse_not_blocked_by_padding_bottom.rs index 14a9637cf..e0f218269 100644 --- a/tests/generated/block_margin_y_first_child_collapse_not_blocked_by_padding_bottom.rs +++ b/tests/generated/block_margin_y_first_child_collapse_not_blocked_by_padding_bottom.rs @@ -3,78 +3,70 @@ fn block_margin_y_first_child_collapse_not_blocked_by_padding_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - padding: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentage::Length(1f32), - }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + padding: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentage::Length(1f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node, 21f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 11f32, "height of node {:?}. Expected {}. Actual {}", node0, 11f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_positive_and_negative.rs b/tests/generated/block_margin_y_first_child_collapse_positive_and_negative.rs index 52a1533e5..9129d3126 100644 --- a/tests/generated/block_margin_y_first_child_collapse_positive_and_negative.rs +++ b/tests/generated/block_margin_y_first_child_collapse_positive_and_negative.rs @@ -3,174 +3,154 @@ fn block_margin_y_first_child_collapse_positive_and_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node100 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: zero(), - }, - ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: zero(), }, - &[node100], - ) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: zero(), - }, - ..Default::default() + ..Default::default() + }, + &[node00], + ); + let node100 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node10 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: zero(), }, - &[node10], - ) - .unwrap(); - let node200 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, ..Default::default() - }) - .unwrap(); - let node20 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + }, + &[node100], + ); + let node1 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: zero(), }, - &[node200], - ) - .unwrap(); - let node2 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-5f32), - bottom: zero(), - }, - ..Default::default() + ..Default::default() + }, + &[node10], + ); + let node200 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node20 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node20], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node200], + ); + let node2 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-5f32), + bottom: zero(), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node20], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node100).unwrap(); + let Layout { size, location, .. } = taffy.layout(node100); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node100, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node20).unwrap(); + let Layout { size, location, .. } = taffy.layout(node20); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node200).unwrap(); + let Layout { size, location, .. } = taffy.layout(node200); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node200, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node200, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node200, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_positive_equal.rs b/tests/generated/block_margin_y_first_child_collapse_positive_equal.rs index 017c1321e..6a9880863 100644 --- a/tests/generated/block_margin_y_first_child_collapse_positive_equal.rs +++ b/tests/generated/block_margin_y_first_child_collapse_positive_equal.rs @@ -3,72 +3,64 @@ fn block_margin_y_first_child_collapse_positive_equal() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_positive_parent_larger.rs b/tests/generated/block_margin_y_first_child_collapse_positive_parent_larger.rs index fd3e54043..5d60b5407 100644 --- a/tests/generated/block_margin_y_first_child_collapse_positive_parent_larger.rs +++ b/tests/generated/block_margin_y_first_child_collapse_positive_parent_larger.rs @@ -3,72 +3,64 @@ fn block_margin_y_first_child_collapse_positive_parent_larger() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_child_collapse_positive_parent_smaller.rs b/tests/generated/block_margin_y_first_child_collapse_positive_parent_smaller.rs index 1bee2fcdb..774384d83 100644 --- a/tests/generated/block_margin_y_first_child_collapse_positive_parent_smaller.rs +++ b/tests/generated/block_margin_y_first_child_collapse_positive_parent_smaller.rs @@ -3,72 +3,64 @@ fn block_margin_y_first_child_collapse_positive_parent_smaller() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_granchild_collapse_positive_and_negative.rs b/tests/generated/block_margin_y_first_granchild_collapse_positive_and_negative.rs index 6df3cebd7..1bbfea437 100644 --- a/tests/generated/block_margin_y_first_granchild_collapse_positive_and_negative.rs +++ b/tests/generated/block_margin_y_first_granchild_collapse_positive_and_negative.rs @@ -3,234 +3,208 @@ fn block_margin_y_first_granchild_collapse_positive_and_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node000 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node0000], - ) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + let node0000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node000 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: zero(), }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: zero(), - }, - ..Default::default() + ..Default::default() + }, + &[node0000], + ); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node1000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, ..Default::default() - }) - .unwrap(); - let node100 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-2f32), - bottom: zero(), - }, - ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: zero(), }, - &[node1000], - ) - .unwrap(); - let node10 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: zero(), - }, - ..Default::default() + ..Default::default() + }, + &[node00], + ); + let node1000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node100 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-2f32), + bottom: zero(), }, - &[node100], - ) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: zero(), - }, - ..Default::default() + ..Default::default() + }, + &[node1000], + ); + let node10 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: zero(), }, - &[node10], - ) - .unwrap(); - let node2000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, ..Default::default() - }) - .unwrap(); - let node200 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(15f32), - bottom: zero(), - }, - ..Default::default() + }, + &[node100], + ); + let node1 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: zero(), }, - &[node2000], - ) - .unwrap(); - let node20 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: zero(), - }, - ..Default::default() + ..Default::default() + }, + &[node10], + ); + let node2000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node200 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(15f32), + bottom: zero(), }, - &[node200], - ) - .unwrap(); - let node2 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: zero(), - }, - ..Default::default() + ..Default::default() + }, + &[node2000], + ); + let node20 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: zero(), }, - &[node20], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node200], + ); + let node2 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: zero(), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node20], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node100).unwrap(); + let Layout { size, location, .. } = taffy.layout(node100); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node100, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node20).unwrap(); + let Layout { size, location, .. } = taffy.layout(node20); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node200).unwrap(); + let Layout { size, location, .. } = taffy.layout(node200); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node200, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node200, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node200, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node200, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_first_granchild_collapse_positive_equal.rs b/tests/generated/block_margin_y_first_granchild_collapse_positive_equal.rs index 1955a45db..4ad76fc22 100644 --- a/tests/generated/block_margin_y_first_granchild_collapse_positive_equal.rs +++ b/tests/generated/block_margin_y_first_granchild_collapse_positive_equal.rs @@ -3,92 +3,82 @@ fn block_margin_y_first_granchild_collapse_positive_equal() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node000 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node0000], - ) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + let node0000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node000 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + ..Default::default() + }, + &[node0000], + ); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_blocked_by_border_bottom.rs b/tests/generated/block_margin_y_last_child_collapse_blocked_by_border_bottom.rs index 2a6c51adb..8243946a7 100644 --- a/tests/generated/block_margin_y_last_child_collapse_blocked_by_border_bottom.rs +++ b/tests/generated/block_margin_y_last_child_collapse_blocked_by_border_bottom.rs @@ -3,72 +3,64 @@ fn block_margin_y_last_child_collapse_blocked_by_border_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden.rs b/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden.rs index 188f440d7..96f1a801c 100644 --- a/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden.rs +++ b/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden.rs @@ -3,77 +3,66 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Visible, - }, - scrollbar_width: 15f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Visible }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll.rs b/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll.rs index 1c737096c..49ee989ac 100644 --- a/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll.rs +++ b/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll.rs @@ -3,77 +3,66 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Visible, - }, - scrollbar_width: 15f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Visible }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node, 45f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden.rs b/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden.rs index 0e9cc3a2b..884bc9aad 100644 --- a/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden.rs +++ b/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden.rs @@ -3,77 +3,66 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Visible, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll.rs b/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll.rs index 96876abe0..1afaccdc4 100644 --- a/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll.rs +++ b/tests/generated/block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll.rs @@ -3,77 +3,66 @@ fn block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Visible, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node00, 35f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node000, 35f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_blocked_by_padding_bottom.rs b/tests/generated/block_margin_y_last_child_collapse_blocked_by_padding_bottom.rs index 2ebecb3c9..4fe39e374 100644 --- a/tests/generated/block_margin_y_last_child_collapse_blocked_by_padding_bottom.rs +++ b/tests/generated/block_margin_y_last_child_collapse_blocked_by_padding_bottom.rs @@ -3,78 +3,70 @@ fn block_margin_y_last_child_collapse_blocked_by_padding_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - padding: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentage::Length(1f32), - }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + padding: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentage::Length(1f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node, 31f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node0, 21f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_negative_equal.rs b/tests/generated/block_margin_y_last_child_collapse_negative_equal.rs index d4f673632..b895b9425 100644 --- a/tests/generated/block_margin_y_last_child_collapse_negative_equal.rs +++ b/tests/generated/block_margin_y_last_child_collapse_negative_equal.rs @@ -3,72 +3,64 @@ fn block_margin_y_last_child_collapse_negative_equal() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_negative_parent_larger.rs b/tests/generated/block_margin_y_last_child_collapse_negative_parent_larger.rs index 414b1eef2..7f5582b4b 100644 --- a/tests/generated/block_margin_y_last_child_collapse_negative_parent_larger.rs +++ b/tests/generated/block_margin_y_last_child_collapse_negative_parent_larger.rs @@ -3,72 +3,64 @@ fn block_margin_y_last_child_collapse_negative_parent_larger() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(-5f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(-5f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_negative_parent_smaller.rs b/tests/generated/block_margin_y_last_child_collapse_negative_parent_smaller.rs index fa925d5a7..32b9e3b8e 100644 --- a/tests/generated/block_margin_y_last_child_collapse_negative_parent_smaller.rs +++ b/tests/generated/block_margin_y_last_child_collapse_negative_parent_smaller.rs @@ -3,72 +3,64 @@ fn block_margin_y_last_child_collapse_negative_parent_smaller() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(-5f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(-5f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_not_blocked_by_border_top.rs b/tests/generated/block_margin_y_last_child_collapse_not_blocked_by_border_top.rs index 3c32de12e..b417f0b93 100644 --- a/tests/generated/block_margin_y_last_child_collapse_not_blocked_by_border_top.rs +++ b/tests/generated/block_margin_y_last_child_collapse_not_blocked_by_border_top.rs @@ -3,72 +3,64 @@ fn block_margin_y_last_child_collapse_not_blocked_by_border_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_not_blocked_by_padding_top.rs b/tests/generated/block_margin_y_last_child_collapse_not_blocked_by_padding_top.rs index 7144d4d48..59914818f 100644 --- a/tests/generated/block_margin_y_last_child_collapse_not_blocked_by_padding_top.rs +++ b/tests/generated/block_margin_y_last_child_collapse_not_blocked_by_padding_top.rs @@ -3,78 +3,70 @@ fn block_margin_y_last_child_collapse_not_blocked_by_padding_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - padding: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: zero(), - }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + padding: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 21f32, "height of node {:?}. Expected {}. Actual {}", node, 21f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 11f32, "height of node {:?}. Expected {}. Actual {}", node0, 11f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node00, 1f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_positive_and_negative.rs b/tests/generated/block_margin_y_last_child_collapse_positive_and_negative.rs index 1a7ad113f..dbfc31fcd 100644 --- a/tests/generated/block_margin_y_last_child_collapse_positive_and_negative.rs +++ b/tests/generated/block_margin_y_last_child_collapse_positive_and_negative.rs @@ -3,174 +3,154 @@ fn block_margin_y_last_child_collapse_positive_and_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node00], - ) - .unwrap(); - let node100 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), - }, - ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), }, - &[node100], - ) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, - ..Default::default() + ..Default::default() + }, + &[node00], + ); + let node100 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node10 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), }, - &[node10], - ) - .unwrap(); - let node200 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, ..Default::default() - }) - .unwrap(); - let node20 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + }, + &[node100], + ); + let node1 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), }, - &[node200], - ) - .unwrap(); - let node2 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(-5f32), - }, - ..Default::default() + ..Default::default() + }, + &[node10], + ); + let node200 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node20 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node20], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node200], + ); + let node2 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(-5f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node20], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node100).unwrap(); + let Layout { size, location, .. } = taffy.layout(node100); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node100, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node2, 15f32, location.y); - let Layout { size, location, .. } = taffy.layout(node20).unwrap(); + let Layout { size, location, .. } = taffy.layout(node20); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node200).unwrap(); + let Layout { size, location, .. } = taffy.layout(node200); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node200, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node200, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node200, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_positive_equal.rs b/tests/generated/block_margin_y_last_child_collapse_positive_equal.rs index 75a27413d..3745ff3dd 100644 --- a/tests/generated/block_margin_y_last_child_collapse_positive_equal.rs +++ b/tests/generated/block_margin_y_last_child_collapse_positive_equal.rs @@ -3,72 +3,64 @@ fn block_margin_y_last_child_collapse_positive_equal() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_positive_parent_larger.rs b/tests/generated/block_margin_y_last_child_collapse_positive_parent_larger.rs index a33c5b377..2d79c70f1 100644 --- a/tests/generated/block_margin_y_last_child_collapse_positive_parent_larger.rs +++ b/tests/generated/block_margin_y_last_child_collapse_positive_parent_larger.rs @@ -3,72 +3,64 @@ fn block_margin_y_last_child_collapse_positive_parent_larger() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_child_collapse_positive_parent_smaller.rs b/tests/generated/block_margin_y_last_child_collapse_positive_parent_smaller.rs index f01ec4f35..16659a24c 100644 --- a/tests/generated/block_margin_y_last_child_collapse_positive_parent_smaller.rs +++ b/tests/generated/block_margin_y_last_child_collapse_positive_parent_smaller.rs @@ -3,72 +3,64 @@ fn block_margin_y_last_child_collapse_positive_parent_smaller() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_last_granchild_collapse_positive_equal.rs b/tests/generated/block_margin_y_last_granchild_collapse_positive_equal.rs index 21fa366df..f9965960d 100644 --- a/tests/generated/block_margin_y_last_granchild_collapse_positive_equal.rs +++ b/tests/generated/block_margin_y_last_granchild_collapse_positive_equal.rs @@ -3,92 +3,82 @@ fn block_margin_y_last_granchild_collapse_positive_equal() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node000 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - &[node0000], - ) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + let node0000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node000 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + ..Default::default() + }, + &[node0000], + ); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0000, 0f32, location.x); diff --git a/tests/generated/block_margin_y_sibling_collapse_negative.rs b/tests/generated/block_margin_y_sibling_collapse_negative.rs index 5a957a688..f9ce78b95 100644 --- a/tests/generated/block_margin_y_sibling_collapse_negative.rs +++ b/tests/generated/block_margin_y_sibling_collapse_negative.rs @@ -3,89 +3,79 @@ fn block_margin_y_sibling_collapse_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-5f32), + bottom: taffy::style::LengthPercentageAuto::Length(-5f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-5f32), - bottom: taffy::style::LengthPercentageAuto::Length(-5f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node1, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node2, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); diff --git a/tests/generated/block_margin_y_sibling_collapse_negative_percentage.rs b/tests/generated/block_margin_y_sibling_collapse_negative_percentage.rs index 003bc7c3d..49e7da62b 100644 --- a/tests/generated/block_margin_y_sibling_collapse_negative_percentage.rs +++ b/tests/generated/block_margin_y_sibling_collapse_negative_percentage.rs @@ -3,89 +3,79 @@ fn block_margin_y_sibling_collapse_negative_percentage() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(-0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(-0.05f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(-0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(-0.05f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node, 15f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node0, -5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node2, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); diff --git a/tests/generated/block_margin_y_sibling_collapse_positive.rs b/tests/generated/block_margin_y_sibling_collapse_positive.rs index 51ea38ace..bddc2cb5f 100644 --- a/tests/generated/block_margin_y_sibling_collapse_positive.rs +++ b/tests/generated/block_margin_y_sibling_collapse_positive.rs @@ -3,89 +3,79 @@ fn block_margin_y_sibling_collapse_positive() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node, 90f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); diff --git a/tests/generated/block_margin_y_sibling_collapse_positive_and_negative.rs b/tests/generated/block_margin_y_sibling_collapse_positive_and_negative.rs index 683956ac4..93e674d14 100644 --- a/tests/generated/block_margin_y_sibling_collapse_positive_and_negative.rs +++ b/tests/generated/block_margin_y_sibling_collapse_positive_and_negative.rs @@ -3,140 +3,124 @@ fn block_margin_y_sibling_collapse_positive_and_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(-5f32), + }, + ..Default::default() + }); + let node6 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(-5f32), - }, - ..Default::default() - }) - .unwrap(); - let node6 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node, 90f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node2, 35f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node5, 55f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node6, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node6, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); diff --git a/tests/generated/block_margin_y_sibling_collapse_positive_and_negative_percentage.rs b/tests/generated/block_margin_y_sibling_collapse_positive_and_negative_percentage.rs index 7d60e8eef..4df444818 100644 --- a/tests/generated/block_margin_y_sibling_collapse_positive_and_negative_percentage.rs +++ b/tests/generated/block_margin_y_sibling_collapse_positive_and_negative_percentage.rs @@ -3,140 +3,124 @@ fn block_margin_y_sibling_collapse_positive_and_negative_percentage() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(-0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(-0.05f32), + }, + ..Default::default() + }); + let node6 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(-0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(-0.05f32), - }, - ..Default::default() - }) - .unwrap(); - let node6 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node1, 15f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 28f32, "y of node {:?}. Expected {}. Actual {}", node2, 28f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node3, 35f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node4, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 53f32, "y of node {:?}. Expected {}. Actual {}", node5, 53f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node6, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node6, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); diff --git a/tests/generated/block_margin_y_sibling_collapse_positive_percentage.rs b/tests/generated/block_margin_y_sibling_collapse_positive_percentage.rs index 19efac9a5..93e8756b7 100644 --- a/tests/generated/block_margin_y_sibling_collapse_positive_percentage.rs +++ b/tests/generated/block_margin_y_sibling_collapse_positive_percentage.rs @@ -3,89 +3,79 @@ fn block_margin_y_sibling_collapse_positive_percentage() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 65f32, "height of node {:?}. Expected {}. Actual {}", node, 65f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node2, 35f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); diff --git a/tests/generated/block_margin_y_simple_negative.rs b/tests/generated/block_margin_y_simple_negative.rs index 696cc3cef..c32881579 100644 --- a/tests/generated/block_margin_y_simple_negative.rs +++ b/tests/generated/block_margin_y_simple_negative.rs @@ -3,49 +3,43 @@ fn block_margin_y_simple_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_y_simple_negative_percentage_other.rs b/tests/generated/block_margin_y_simple_negative_percentage_other.rs index 7f767e945..887ce4af7 100644 --- a/tests/generated/block_margin_y_simple_negative_percentage_other.rs +++ b/tests/generated/block_margin_y_simple_negative_percentage_other.rs @@ -3,52 +3,46 @@ fn block_margin_y_simple_negative_percentage_other() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node0, -5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_y_simple_negative_percentage_self.rs b/tests/generated/block_margin_y_simple_negative_percentage_self.rs index 5cb1a9dc9..40c2fc82e 100644 --- a/tests/generated/block_margin_y_simple_negative_percentage_self.rs +++ b/tests/generated/block_margin_y_simple_negative_percentage_self.rs @@ -3,52 +3,46 @@ fn block_margin_y_simple_negative_percentage_self() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(-0.1f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(-0.1f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node0, -5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_y_simple_positive.rs b/tests/generated/block_margin_y_simple_positive.rs index 3c8f3eef3..b05497df0 100644 --- a/tests/generated/block_margin_y_simple_positive.rs +++ b/tests/generated/block_margin_y_simple_positive.rs @@ -3,49 +3,43 @@ fn block_margin_y_simple_positive() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_y_simple_positive_percentage_other.rs b/tests/generated/block_margin_y_simple_positive_percentage_other.rs index 957c65aaf..270f1b7c7 100644 --- a/tests/generated/block_margin_y_simple_positive_percentage_other.rs +++ b/tests/generated/block_margin_y_simple_positive_percentage_other.rs @@ -3,48 +3,42 @@ fn block_margin_y_simple_positive_percentage_other() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_y_simple_positive_percentage_self.rs b/tests/generated/block_margin_y_simple_positive_percentage_self.rs index 4a9481d95..efac608e5 100644 --- a/tests/generated/block_margin_y_simple_positive_percentage_self.rs +++ b/tests/generated/block_margin_y_simple_positive_percentage_self.rs @@ -3,48 +3,42 @@ fn block_margin_y_simple_positive_percentage_self() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/block_margin_y_total_collapse.rs b/tests/generated/block_margin_y_total_collapse.rs index 942b16fbe..7268af382 100644 --- a/tests/generated/block_margin_y_total_collapse.rs +++ b/tests/generated/block_margin_y_total_collapse.rs @@ -3,22 +3,42 @@ fn block_margin_y_total_collapse() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node02 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, margin: taffy::geometry::Rect { left: zero(), right: zero(), @@ -26,72 +46,42 @@ fn block_margin_y_total_collapse() { bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, ..Default::default() - }) - .unwrap(); - let node02 = taffy - .new_leaf(taffy::style::Style { + }, + &[node00, node01, node02], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - &[node00, node01, node02], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node01, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node01, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node02).unwrap(); + let Layout { size, location, .. } = taffy.layout(node02); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node02, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node02, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); diff --git a/tests/generated/block_margin_y_total_collapse_complex.rs b/tests/generated/block_margin_y_total_collapse_complex.rs index f9cc49aa3..42275907d 100644 --- a/tests/generated/block_margin_y_total_collapse_complex.rs +++ b/tests/generated/block_margin_y_total_collapse_complex.rs @@ -3,8 +3,48 @@ fn block_margin_y_total_collapse_complex() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-5f32), + bottom: taffy::style::LengthPercentageAuto::Length(-5f32), + }, + ..Default::default() + }); + let node11 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(7f32), + bottom: taffy::style::LengthPercentageAuto::Length(3f32), + }, + ..Default::default() + }); + let node12 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-6f32), + bottom: taffy::style::LengthPercentageAuto::Length(9f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, margin: taffy::geometry::Rect { left: zero(), @@ -13,133 +53,77 @@ fn block_margin_y_total_collapse_complex() { bottom: taffy::style::LengthPercentageAuto::Length(-10f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-5f32), - bottom: taffy::style::LengthPercentageAuto::Length(-5f32), - }, - ..Default::default() - }) - .unwrap(); - let node11 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(7f32), - bottom: taffy::style::LengthPercentageAuto::Length(3f32), - }, - ..Default::default() - }) - .unwrap(); - let node12 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-6f32), - bottom: taffy::style::LengthPercentageAuto::Length(9f32), - }, + }, + &[node10, node11, node12], + ); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-5f32), + bottom: taffy::style::LengthPercentageAuto::Length(-5f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(-10f32), + bottom: taffy::style::LengthPercentageAuto::Length(-10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, - ..Default::default() - }, - &[node10, node11, node12], - ) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-5f32), - bottom: taffy::style::LengthPercentageAuto::Length(-5f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(-10f32), - bottom: taffy::style::LengthPercentageAuto::Length(-10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node0, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node1, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node10, -5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node11, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); assert_eq!(location.y, 7f32, "y of node {:?}. Expected {}. Actual {}", node11, 7f32, location.y); - let Layout { size, location, .. } = taffy.layout(node12).unwrap(); + let Layout { size, location, .. } = taffy.layout(node12); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node12, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node12, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); assert_eq!(location.y, -6f32, "y of node {:?}. Expected {}. Actual {}", node12, -6f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node2, -10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); diff --git a/tests/generated/block_overflow_scrollbars_overriden_by_available_space.rs b/tests/generated/block_overflow_scrollbars_overriden_by_available_space.rs index 4595b4ba5..c867f7088 100644 --- a/tests/generated/block_overflow_scrollbars_overriden_by_available_space.rs +++ b/tests/generated/block_overflow_scrollbars_overriden_by_available_space.rs @@ -3,60 +3,51 @@ fn block_overflow_scrollbars_overriden_by_available_space() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(4f32), - }, - ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(4f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node0, 15f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/block_overflow_scrollbars_overriden_by_max_size.rs b/tests/generated/block_overflow_scrollbars_overriden_by_max_size.rs index c08dc9de5..e00767c1c 100644 --- a/tests/generated/block_overflow_scrollbars_overriden_by_max_size.rs +++ b/tests/generated/block_overflow_scrollbars_overriden_by_max_size.rs @@ -3,46 +3,39 @@ fn block_overflow_scrollbars_overriden_by_max_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(4f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(4f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_overflow_scrollbars_overriden_by_size.rs b/tests/generated/block_overflow_scrollbars_overriden_by_size.rs index e53a02893..b4f2f9e3c 100644 --- a/tests/generated/block_overflow_scrollbars_overriden_by_size.rs +++ b/tests/generated/block_overflow_scrollbars_overriden_by_size.rs @@ -3,46 +3,39 @@ fn block_overflow_scrollbars_overriden_by_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(4f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(4f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_overflow_scrollbars_take_up_space_both_axis.rs b/tests/generated/block_overflow_scrollbars_take_up_space_both_axis.rs index c89de6ce5..f7c371235 100644 --- a/tests/generated/block_overflow_scrollbars_take_up_space_both_axis.rs +++ b/tests/generated/block_overflow_scrollbars_take_up_space_both_axis.rs @@ -3,46 +3,39 @@ fn block_overflow_scrollbars_take_up_space_both_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_overflow_scrollbars_take_up_space_cross_axis.rs b/tests/generated/block_overflow_scrollbars_take_up_space_cross_axis.rs index d5e8b5457..04d84109a 100644 --- a/tests/generated/block_overflow_scrollbars_take_up_space_cross_axis.rs +++ b/tests/generated/block_overflow_scrollbars_take_up_space_cross_axis.rs @@ -3,46 +3,39 @@ fn block_overflow_scrollbars_take_up_space_cross_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Visible, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_overflow_scrollbars_take_up_space_main_axis.rs b/tests/generated/block_overflow_scrollbars_take_up_space_main_axis.rs index 769039bae..b8935ac31 100644 --- a/tests/generated/block_overflow_scrollbars_take_up_space_main_axis.rs +++ b/tests/generated/block_overflow_scrollbars_take_up_space_main_axis.rs @@ -3,46 +3,39 @@ fn block_overflow_scrollbars_take_up_space_main_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Visible }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Visible, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/block_padding_border_fixed_size.rs b/tests/generated/block_padding_border_fixed_size.rs index 52293bf36..d51885d17 100644 --- a/tests/generated/block_padding_border_fixed_size.rs +++ b/tests/generated/block_padding_border_fixed_size.rs @@ -3,58 +3,52 @@ fn block_padding_border_fixed_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node0, 28f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node1, 28f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node1, 15f32, location.x); diff --git a/tests/generated/block_padding_border_intrinsic_size.rs b/tests/generated/block_padding_border_intrinsic_size.rs index ea7c87e67..59cdea1ac 100644 --- a/tests/generated/block_padding_border_intrinsic_size.rs +++ b/tests/generated/block_padding_border_intrinsic_size.rs @@ -3,57 +3,51 @@ fn block_padding_border_intrinsic_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node, 72f32, size.width); assert_eq!(size.height, 34f32, "height of node {:?}. Expected {}. Actual {}", node, 34f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node1, 15f32, location.x); diff --git a/tests/generated/block_padding_border_overrides_max_size.rs b/tests/generated/block_padding_border_overrides_max_size.rs index 0aa729014..71258d30c 100644 --- a/tests/generated/block_padding_border_overrides_max_size.rs +++ b/tests/generated/block_padding_border_overrides_max_size.rs @@ -3,53 +3,49 @@ fn block_padding_border_overrides_max_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() + let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node00, 15f32, location.x); diff --git a/tests/generated/block_padding_border_overrides_min_size.rs b/tests/generated/block_padding_border_overrides_min_size.rs index fb05863c3..5a3051733 100644 --- a/tests/generated/block_padding_border_overrides_min_size.rs +++ b/tests/generated/block_padding_border_overrides_min_size.rs @@ -3,53 +3,49 @@ fn block_padding_border_overrides_min_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(0f32), - height: taffy::style::Dimension::Length(0f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() + let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(0f32), + height: taffy::style::Dimension::Length(0f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node00, 15f32, location.x); diff --git a/tests/generated/block_padding_border_overrides_size.rs b/tests/generated/block_padding_border_overrides_size.rs index 9db2835b6..30d080494 100644 --- a/tests/generated/block_padding_border_overrides_size.rs +++ b/tests/generated/block_padding_border_overrides_size.rs @@ -3,53 +3,49 @@ fn block_padding_border_overrides_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() + let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node00, 15f32, location.x); diff --git a/tests/generated/block_padding_border_percentage_fixed_size.rs b/tests/generated/block_padding_border_percentage_fixed_size.rs index a4db79572..7c89d9349 100644 --- a/tests/generated/block_padding_border_percentage_fixed_size.rs +++ b/tests/generated/block_padding_border_percentage_fixed_size.rs @@ -3,56 +3,50 @@ fn block_padding_border_percentage_fixed_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Percent(0.04f32), - right: taffy::style::LengthPercentage::Percent(0.02f32), - top: taffy::style::LengthPercentage::Percent(0.01f32), - bottom: taffy::style::LengthPercentage::Percent(0.03f32), - }, - ..Default::default() + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Percent(0.04f32), + right: taffy::style::LengthPercentage::Percent(0.02f32), + top: taffy::style::LengthPercentage::Percent(0.01f32), + bottom: taffy::style::LengthPercentage::Percent(0.03f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node0, 12f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 47f32, "width of node {:?}. Expected {}. Actual {}", node00, 47f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node00, 2f32, location.x); diff --git a/tests/generated/block_padding_border_percentage_intrinsic_size.rs b/tests/generated/block_padding_border_percentage_intrinsic_size.rs index 7021835fa..ce6e0f95b 100644 --- a/tests/generated/block_padding_border_percentage_intrinsic_size.rs +++ b/tests/generated/block_padding_border_percentage_intrinsic_size.rs @@ -3,49 +3,43 @@ fn block_padding_border_percentage_intrinsic_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Percent(0.04f32), - right: taffy::style::LengthPercentage::Percent(0.02f32), - top: taffy::style::LengthPercentage::Percent(0.01f32), - bottom: taffy::style::LengthPercentage::Percent(0.03f32), - }, - ..Default::default() + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Percent(0.04f32), + right: taffy::style::LengthPercentage::Percent(0.02f32), + top: taffy::style::LengthPercentage::Percent(0.01f32), + bottom: taffy::style::LengthPercentage::Percent(0.03f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/block_padding_fixed_size.rs b/tests/generated/block_padding_fixed_size.rs index 6c6bbfdfb..f47ebc6f1 100644 --- a/tests/generated/block_padding_fixed_size.rs +++ b/tests/generated/block_padding_fixed_size.rs @@ -3,52 +3,46 @@ fn block_padding_fixed_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 38f32, "width of node {:?}. Expected {}. Actual {}", node0, 38f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 38f32, "width of node {:?}. Expected {}. Actual {}", node1, 38f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); diff --git a/tests/generated/block_padding_intrinsic_size.rs b/tests/generated/block_padding_intrinsic_size.rs index 91e8fe420..920cfc54d 100644 --- a/tests/generated/block_padding_intrinsic_size.rs +++ b/tests/generated/block_padding_intrinsic_size.rs @@ -3,51 +3,45 @@ fn block_padding_intrinsic_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node, 62f32, size.width); assert_eq!(size.height, 28f32, "height of node {:?}. Expected {}. Actual {}", node, 28f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1, 8f32, location.x); diff --git a/tests/generated/block_padding_percentage_fixed_size.rs b/tests/generated/block_padding_percentage_fixed_size.rs index 05a523698..b24182eb7 100644 --- a/tests/generated/block_padding_percentage_fixed_size.rs +++ b/tests/generated/block_padding_percentage_fixed_size.rs @@ -3,56 +3,50 @@ fn block_padding_percentage_fixed_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Percent(0.04f32), - right: taffy::style::LengthPercentage::Percent(0.02f32), - top: taffy::style::LengthPercentage::Percent(0.01f32), - bottom: taffy::style::LengthPercentage::Percent(0.03f32), - }, - ..Default::default() + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Percent(0.04f32), + right: taffy::style::LengthPercentage::Percent(0.02f32), + top: taffy::style::LengthPercentage::Percent(0.01f32), + bottom: taffy::style::LengthPercentage::Percent(0.03f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node0, 12f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 47f32, "width of node {:?}. Expected {}. Actual {}", node00, 47f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node00, 2f32, location.x); diff --git a/tests/generated/block_padding_percentage_intrinsic_size.rs b/tests/generated/block_padding_percentage_intrinsic_size.rs index 2b0ed8bda..6672fa6dc 100644 --- a/tests/generated/block_padding_percentage_intrinsic_size.rs +++ b/tests/generated/block_padding_percentage_intrinsic_size.rs @@ -3,49 +3,43 @@ fn block_padding_percentage_intrinsic_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Percent(0.04f32), - right: taffy::style::LengthPercentage::Percent(0.02f32), - top: taffy::style::LengthPercentage::Percent(0.01f32), - bottom: taffy::style::LengthPercentage::Percent(0.03f32), - }, - ..Default::default() + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Percent(0.04f32), + right: taffy::style::LengthPercentage::Percent(0.02f32), + top: taffy::style::LengthPercentage::Percent(0.01f32), + bottom: taffy::style::LengthPercentage::Percent(0.03f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/blockflex_block_in_flex_column.rs b/tests/generated/blockflex_block_in_flex_column.rs index 4a1df8fed..5fd34a383 100644 --- a/tests/generated/blockflex_block_in_flex_column.rs +++ b/tests/generated/blockflex_block_in_flex_column.rs @@ -3,44 +3,39 @@ fn blockflex_block_in_flex_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockflex_block_in_flex_row.rs b/tests/generated/blockflex_block_in_flex_row.rs index 328ec065e..b98ac2f56 100644 --- a/tests/generated/blockflex_block_in_flex_row.rs +++ b/tests/generated/blockflex_block_in_flex_row.rs @@ -3,43 +3,38 @@ fn blockflex_block_in_flex_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockflex_flex_in_block.rs b/tests/generated/blockflex_flex_in_block.rs index bc05c0f55..20ba7aa7f 100644 --- a/tests/generated/blockflex_flex_in_block.rs +++ b/tests/generated/blockflex_flex_in_block.rs @@ -3,61 +3,53 @@ fn blockflex_flex_in_block() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Flex, ..Default::default() }, - &[node00], - ) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Flex, ..Default::default() }, + &[node00], + ); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node, 70f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockflex_margin_y_collapse_through_blocked_by_flex.rs b/tests/generated/blockflex_margin_y_collapse_through_blocked_by_flex.rs index f0ba3ab01..4a1e34883 100644 --- a/tests/generated/blockflex_margin_y_collapse_through_blocked_by_flex.rs +++ b/tests/generated/blockflex_margin_y_collapse_through_blocked_by_flex.rs @@ -3,74 +3,66 @@ fn blockflex_margin_y_collapse_through_blocked_by_flex() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Flex, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Flex, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/blockflex_margin_y_first_child_collapse_blocked_by_flex.rs b/tests/generated/blockflex_margin_y_first_child_collapse_blocked_by_flex.rs index 68fb71002..9ee2da603 100644 --- a/tests/generated/blockflex_margin_y_first_child_collapse_blocked_by_flex.rs +++ b/tests/generated/blockflex_margin_y_first_child_collapse_blocked_by_flex.rs @@ -3,72 +3,64 @@ fn blockflex_margin_y_first_child_collapse_blocked_by_flex() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/blockflex_margin_y_last_child_collapse_blocked_by_flex.rs b/tests/generated/blockflex_margin_y_last_child_collapse_blocked_by_flex.rs index 39bf73082..231807736 100644 --- a/tests/generated/blockflex_margin_y_last_child_collapse_blocked_by_flex.rs +++ b/tests/generated/blockflex_margin_y_last_child_collapse_blocked_by_flex.rs @@ -3,72 +3,64 @@ fn blockflex_margin_y_last_child_collapse_blocked_by_flex() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/blockflex_overflow_hidden.rs b/tests/generated/blockflex_overflow_hidden.rs index 0a897d0a0..9ccdf1f9a 100644 --- a/tests/generated/blockflex_overflow_hidden.rs +++ b/tests/generated/blockflex_overflow_hidden.rs @@ -3,73 +3,52 @@ fn blockflex_overflow_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - display: taffy::style::Display::Block, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - flex_grow: 1f32, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + flex_grow: 1f32, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { display: taffy::style::Display::Block, flex_grow: 1f32, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(50f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { display: taffy::style::Display::Block, flex_grow: 1f32, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockgrid_block_in_grid_auto.rs b/tests/generated/blockgrid_block_in_grid_auto.rs index 22e5bbce8..a3dd84ceb 100644 --- a/tests/generated/blockgrid_block_in_grid_auto.rs +++ b/tests/generated/blockgrid_block_in_grid_auto.rs @@ -3,48 +3,37 @@ fn blockgrid_block_in_grid_auto() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_columns: vec![auto()], - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_columns: vec![auto()], + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockgrid_block_in_grid_fixed_fit_content_larger.rs b/tests/generated/blockgrid_block_in_grid_fixed_fit_content_larger.rs index c3eaed433..6c1c62cb3 100644 --- a/tests/generated/blockgrid_block_in_grid_fixed_fit_content_larger.rs +++ b/tests/generated/blockgrid_block_in_grid_fixed_fit_content_larger.rs @@ -3,48 +3,37 @@ fn blockgrid_block_in_grid_fixed_fit_content_larger() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_columns: vec![fit_content(length(50f32))], - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_columns: vec![fit_content(length(50f32))], + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockgrid_block_in_grid_fixed_fit_content_middle.rs b/tests/generated/blockgrid_block_in_grid_fixed_fit_content_middle.rs index 2c66cab15..70cb4c9b6 100644 --- a/tests/generated/blockgrid_block_in_grid_fixed_fit_content_middle.rs +++ b/tests/generated/blockgrid_block_in_grid_fixed_fit_content_middle.rs @@ -3,48 +3,37 @@ fn blockgrid_block_in_grid_fixed_fit_content_middle() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_columns: vec![fit_content(length(30f32))], - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_columns: vec![fit_content(length(30f32))], + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockgrid_block_in_grid_fixed_fit_content_smaller.rs b/tests/generated/blockgrid_block_in_grid_fixed_fit_content_smaller.rs index 70c5f7f42..77d0afdbe 100644 --- a/tests/generated/blockgrid_block_in_grid_fixed_fit_content_smaller.rs +++ b/tests/generated/blockgrid_block_in_grid_fixed_fit_content_smaller.rs @@ -3,48 +3,37 @@ fn blockgrid_block_in_grid_fixed_fit_content_smaller() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_columns: vec![fit_content(length(10f32))], - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_columns: vec![fit_content(length(10f32))], + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockgrid_block_in_grid_fixed_larger.rs b/tests/generated/blockgrid_block_in_grid_fixed_larger.rs index 82b8be720..26fe0b5bd 100644 --- a/tests/generated/blockgrid_block_in_grid_fixed_larger.rs +++ b/tests/generated/blockgrid_block_in_grid_fixed_larger.rs @@ -3,48 +3,37 @@ fn blockgrid_block_in_grid_fixed_larger() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_columns: vec![length(50f32)], - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_columns: vec![length(50f32)], + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockgrid_block_in_grid_fixed_middle.rs b/tests/generated/blockgrid_block_in_grid_fixed_middle.rs index df6bb665c..730dec614 100644 --- a/tests/generated/blockgrid_block_in_grid_fixed_middle.rs +++ b/tests/generated/blockgrid_block_in_grid_fixed_middle.rs @@ -3,48 +3,37 @@ fn blockgrid_block_in_grid_fixed_middle() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_columns: vec![length(30f32)], - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_columns: vec![length(30f32)], + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockgrid_block_in_grid_fixed_smaller.rs b/tests/generated/blockgrid_block_in_grid_fixed_smaller.rs index 166f95e01..7428cf4fa 100644 --- a/tests/generated/blockgrid_block_in_grid_fixed_smaller.rs +++ b/tests/generated/blockgrid_block_in_grid_fixed_smaller.rs @@ -3,48 +3,37 @@ fn blockgrid_block_in_grid_fixed_smaller() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_columns: vec![length(10f32)], - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_columns: vec![length(10f32)], + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockgrid_block_in_grid_fr.rs b/tests/generated/blockgrid_block_in_grid_fr.rs index 5317762f3..15c09dfd6 100644 --- a/tests/generated/blockgrid_block_in_grid_fr.rs +++ b/tests/generated/blockgrid_block_in_grid_fr.rs @@ -3,48 +3,37 @@ fn blockgrid_block_in_grid_fr() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_columns: vec![fr(1f32)], - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_columns: vec![fr(1f32)], + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockgrid_block_in_grid_max_content.rs b/tests/generated/blockgrid_block_in_grid_max_content.rs index a3c997d4b..615446a15 100644 --- a/tests/generated/blockgrid_block_in_grid_max_content.rs +++ b/tests/generated/blockgrid_block_in_grid_max_content.rs @@ -3,48 +3,37 @@ fn blockgrid_block_in_grid_max_content() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_columns: vec![min_content()], - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_columns: vec![min_content()], + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockgrid_block_in_grid_min_content.rs b/tests/generated/blockgrid_block_in_grid_min_content.rs index b0a7cd8b3..bbc1bb0c0 100644 --- a/tests/generated/blockgrid_block_in_grid_min_content.rs +++ b/tests/generated/blockgrid_block_in_grid_min_content.rs @@ -3,48 +3,37 @@ fn blockgrid_block_in_grid_min_content() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_columns: vec![min_content()], - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_columns: vec![min_content()], + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockgrid_grid_in_block.rs b/tests/generated/blockgrid_grid_in_block.rs index 6b6200e9f..8b14ff715 100644 --- a/tests/generated/blockgrid_grid_in_block.rs +++ b/tests/generated/blockgrid_grid_in_block.rs @@ -3,61 +3,53 @@ fn blockgrid_grid_in_block() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, - &[node00], - ) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + &[node00], + ); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node, 70f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/blockgrid_margin_y_collapse_through_blocked_by_grid.rs b/tests/generated/blockgrid_margin_y_collapse_through_blocked_by_grid.rs index fa813fdb8..6f97d41ea 100644 --- a/tests/generated/blockgrid_margin_y_collapse_through_blocked_by_grid.rs +++ b/tests/generated/blockgrid_margin_y_collapse_through_blocked_by_grid.rs @@ -3,74 +3,66 @@ fn blockgrid_margin_y_collapse_through_blocked_by_grid() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/blockgrid_margin_y_first_child_collapse_blocked_by_grid.rs b/tests/generated/blockgrid_margin_y_first_child_collapse_blocked_by_grid.rs index ef578017a..e32b16dc7 100644 --- a/tests/generated/blockgrid_margin_y_first_child_collapse_blocked_by_grid.rs +++ b/tests/generated/blockgrid_margin_y_first_child_collapse_blocked_by_grid.rs @@ -3,72 +3,64 @@ fn blockgrid_margin_y_first_child_collapse_blocked_by_grid() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/blockgrid_margin_y_last_child_collapse_blocked_by_grid.rs b/tests/generated/blockgrid_margin_y_last_child_collapse_blocked_by_grid.rs index 9451053ac..24f9958e5 100644 --- a/tests/generated/blockgrid_margin_y_last_child_collapse_blocked_by_grid.rs +++ b/tests/generated/blockgrid_margin_y_last_child_collapse_blocked_by_grid.rs @@ -3,72 +3,64 @@ fn blockgrid_margin_y_last_child_collapse_blocked_by_grid() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); diff --git a/tests/generated/border_center_child.rs b/tests/generated/border_center_child.rs index 101205234..dc12afd5a 100644 --- a/tests/generated/border_center_child.rs +++ b/tests/generated/border_center_child.rs @@ -3,45 +3,41 @@ fn border_center_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - border: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(20f32), - }, - ..Default::default() + border: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(20f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node0, 45f32, location.x); diff --git a/tests/generated/border_container_match_child.rs b/tests/generated/border_container_match_child.rs index 92edc6bc8..32981b8fd 100644 --- a/tests/generated/border_container_match_child.rs +++ b/tests/generated/border_container_match_child.rs @@ -3,40 +3,36 @@ fn border_container_match_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/border_flex_child.rs b/tests/generated/border_flex_child.rs index 11e792f67..5166d07d0 100644 --- a/tests/generated/border_flex_child.rs +++ b/tests/generated/border_flex_child.rs @@ -3,41 +3,37 @@ fn border_flex_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/border_no_child.rs b/tests/generated/border_no_child.rs index d33dea7cc..7de73d424 100644 --- a/tests/generated/border_no_child.rs +++ b/tests/generated/border_no_child.rs @@ -3,22 +3,20 @@ fn border_no_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), + }, + ..Default::default() + }); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/border_no_size.rs b/tests/generated/border_no_size.rs index d29f4ebd1..53fff36a7 100644 --- a/tests/generated/border_no_size.rs +++ b/tests/generated/border_no_size.rs @@ -3,23 +3,21 @@ fn border_no_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), + }, + ..Default::default() + }); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/border_stretch_child.rs b/tests/generated/border_stretch_child.rs index 961281fcd..b06c959a9 100644 --- a/tests/generated/border_stretch_child.rs +++ b/tests/generated/border_stretch_child.rs @@ -3,40 +3,36 @@ fn border_stretch_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/child_min_max_width_flexing.rs b/tests/generated/child_min_max_width_flexing.rs index f9b3fca1c..d062093fe 100644 --- a/tests/generated/child_min_max_width_flexing.rs +++ b/tests/generated/child_min_max_width_flexing.rs @@ -3,52 +3,46 @@ fn child_min_max_width_flexing() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Length(0f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Percent(0.5f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Length(0f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); diff --git a/tests/generated/child_with_padding_align_end.rs b/tests/generated/child_with_padding_align_end.rs index f4e448115..aa53dd794 100644 --- a/tests/generated/child_with_padding_align_end.rs +++ b/tests/generated/child_with_padding_align_end.rs @@ -3,46 +3,42 @@ fn child_with_padding_align_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(20f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(20f32), + bottom: taffy::style::LengthPercentage::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::FlexEnd), + justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(20f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(20f32), - bottom: taffy::style::LengthPercentage::Length(20f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::FlexEnd), - justify_content: Some(taffy::style::JustifyContent::FlexEnd), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node0, 100f32, location.x); diff --git a/tests/generated/container_with_unsized_child.rs b/tests/generated/container_with_unsized_child.rs index 92c0b9ac1..de84eb1f1 100644 --- a/tests/generated/container_with_unsized_child.rs +++ b/tests/generated/container_with_unsized_child.rs @@ -3,29 +3,27 @@ fn container_with_unsized_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/display_none.rs b/tests/generated/display_none.rs index 34920bdc2..cb0d11892 100644 --- a/tests/generated/display_none.rs +++ b/tests/generated/display_none.rs @@ -3,37 +3,37 @@ fn display_none() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { display: taffy::style::Display::None, flex_grow: 1f32, ..Default::default() }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + flex_grow: 1f32, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/display_none_absolute_child.rs b/tests/generated/display_none_absolute_child.rs index a59d97151..bce34d1de 100644 --- a/tests/generated/display_none_absolute_child.rs +++ b/tests/generated/display_none_absolute_child.rs @@ -3,51 +3,47 @@ fn display_none_absolute_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::None, - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: auto(), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/display_none_fixed_size.rs b/tests/generated/display_none_fixed_size.rs index 4eb8dfab4..b5f6b31f2 100644 --- a/tests/generated/display_none_fixed_size.rs +++ b/tests/generated/display_none_fixed_size.rs @@ -3,44 +3,40 @@ fn display_none_fixed_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::None, + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/display_none_only_node.rs b/tests/generated/display_none_only_node.rs index 590c3678f..54680f449 100644 --- a/tests/generated/display_none_only_node.rs +++ b/tests/generated/display_none_only_node.rs @@ -3,21 +3,19 @@ fn display_none_only_node() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::None, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/display_none_with_child.rs b/tests/generated/display_none_with_child.rs index 17412e659..83dba4fa2 100644 --- a/tests/generated/display_none_with_child.rs +++ b/tests/generated/display_none_with_child.rs @@ -3,81 +3,71 @@ fn display_none_with_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::None, + flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, flex_shrink: 1f32, flex_basis: taffy::style::Dimension::Percent(0f32), ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::None, - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() + }, + &[node10], + ); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node10], - ) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); diff --git a/tests/generated/display_none_with_margin.rs b/tests/generated/display_none_with_margin.rs index f872d14c9..6feddf936 100644 --- a/tests/generated/display_none_with_margin.rs +++ b/tests/generated/display_none_with_margin.rs @@ -3,50 +3,46 @@ fn display_none_with_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::None, + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/display_none_with_position.rs b/tests/generated/display_none_with_position.rs index 1d2de6c5d..e53be5018 100644 --- a/tests/generated/display_none_with_position.rs +++ b/tests/generated/display_none_with_position.rs @@ -3,47 +3,43 @@ fn display_none_with_position() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::None, - flex_grow: 1f32, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + flex_grow: 1f32, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/display_none_with_position_absolute.rs b/tests/generated/display_none_with_position_absolute.rs index 1972d9767..a14d031ba 100644 --- a/tests/generated/display_none_with_position_absolute.rs +++ b/tests/generated/display_none_with_position_absolute.rs @@ -3,39 +3,35 @@ fn display_none_with_position_absolute() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::None, - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent.rs b/tests/generated/do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent.rs index afe52de1e..c161762ac 100644 --- a/tests/generated/do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent.rs +++ b/tests/generated/do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent.rs @@ -3,63 +3,54 @@ fn do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent( #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + position: taffy::style::Position::Absolute, + flex_direction: taffy::style::FlexDirection::Column, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: auto(), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - position: taffy::style::Position::Absolute, - flex_direction: taffy::style::FlexDirection::Column, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/flex_basis_and_main_dimen_set_when_flexing.rs b/tests/generated/flex_basis_and_main_dimen_set_when_flexing.rs index dc91db465..635cf17f9 100644 --- a/tests/generated/flex_basis_and_main_dimen_set_when_flexing.rs +++ b/tests/generated/flex_basis_and_main_dimen_set_when_flexing.rs @@ -3,52 +3,46 @@ fn flex_basis_and_main_dimen_set_when_flexing() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(10f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(0f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(10f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(0f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); diff --git a/tests/generated/flex_basis_flex_grow_column.rs b/tests/generated/flex_basis_flex_grow_column.rs index 2d18ce36e..e33d1e520 100644 --- a/tests/generated/flex_basis_flex_grow_column.rs +++ b/tests/generated/flex_basis_flex_grow_column.rs @@ -3,42 +3,38 @@ fn flex_basis_flex_grow_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(50f32), - ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(50f32), + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 75f32, "height of node {:?}. Expected {}. Actual {}", node0, 75f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/flex_basis_flex_grow_row.rs b/tests/generated/flex_basis_flex_grow_row.rs index df5baa3ea..cc2ed27ab 100644 --- a/tests/generated/flex_basis_flex_grow_row.rs +++ b/tests/generated/flex_basis_flex_grow_row.rs @@ -3,41 +3,37 @@ fn flex_basis_flex_grow_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(50f32), - ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(50f32), + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 75f32, "width of node {:?}. Expected {}. Actual {}", node0, 75f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node1, 25f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node1, 75f32, location.x); diff --git a/tests/generated/flex_basis_flex_shrink_column.rs b/tests/generated/flex_basis_flex_shrink_column.rs index 735ddf102..bb72055f1 100644 --- a/tests/generated/flex_basis_flex_shrink_column.rs +++ b/tests/generated/flex_basis_flex_shrink_column.rs @@ -4,39 +4,35 @@ fn flex_basis_flex_shrink_column() { use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Length(100f32), ..Default::default() }) - .unwrap(); + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Length(100f32), ..Default::default() }); let node1 = taffy - .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Length(50f32), ..Default::default() }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Length(50f32), ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node1, 33f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/flex_basis_flex_shrink_row.rs b/tests/generated/flex_basis_flex_shrink_row.rs index 1693370d2..04780e3b1 100644 --- a/tests/generated/flex_basis_flex_shrink_row.rs +++ b/tests/generated/flex_basis_flex_shrink_row.rs @@ -4,38 +4,34 @@ fn flex_basis_flex_shrink_row() { use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Length(100f32), ..Default::default() }) - .unwrap(); + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Length(100f32), ..Default::default() }); let node1 = taffy - .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Length(50f32), ..Default::default() }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Length(50f32), ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 67f32, "width of node {:?}. Expected {}. Actual {}", node0, 67f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node1, 33f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node1, 67f32, location.x); diff --git a/tests/generated/flex_basis_larger_than_content_column.rs b/tests/generated/flex_basis_larger_than_content_column.rs index 8cd8dedf4..c37ac7909 100644 --- a/tests/generated/flex_basis_larger_than_content_column.rs +++ b/tests/generated/flex_basis_larger_than_content_column.rs @@ -3,50 +3,44 @@ fn flex_basis_larger_than_content_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(10f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_basis: taffy::style::Dimension::Length(50f32), ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_basis: taffy::style::Dimension::Length(50f32), - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/flex_basis_larger_than_content_row.rs b/tests/generated/flex_basis_larger_than_content_row.rs index 1f8a391e0..a37758e7f 100644 --- a/tests/generated/flex_basis_larger_than_content_row.rs +++ b/tests/generated/flex_basis_larger_than_content_row.rs @@ -3,49 +3,43 @@ fn flex_basis_larger_than_content_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_basis: taffy::style::Dimension::Length(50f32), ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_basis: taffy::style::Dimension::Length(50f32), - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/flex_basis_overrides_main_size.rs b/tests/generated/flex_basis_overrides_main_size.rs index 277532cba..ba648584c 100644 --- a/tests/generated/flex_basis_overrides_main_size.rs +++ b/tests/generated/flex_basis_overrides_main_size.rs @@ -3,60 +3,52 @@ fn flex_basis_overrides_main_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(50f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(50f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); diff --git a/tests/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs b/tests/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs index 3ee0e11df..dabfc06bf 100644 --- a/tests/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs +++ b/tests/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs @@ -3,80 +3,70 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(70f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(70f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(60f32), ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(60f32), - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(100f32), - }, + }, + &[node00], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(0f32), ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(0f32), - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/flex_basis_smaller_than_content_column.rs b/tests/generated/flex_basis_smaller_than_content_column.rs index 17cf70936..a6ca2679a 100644 --- a/tests/generated/flex_basis_smaller_than_content_column.rs +++ b/tests/generated/flex_basis_smaller_than_content_column.rs @@ -3,50 +3,44 @@ fn flex_basis_smaller_than_content_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_basis: taffy::style::Dimension::Length(50f32), ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_basis: taffy::style::Dimension::Length(50f32), - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/flex_basis_smaller_than_content_row.rs b/tests/generated/flex_basis_smaller_than_content_row.rs index ccac188d3..14b3cb69b 100644 --- a/tests/generated/flex_basis_smaller_than_content_row.rs +++ b/tests/generated/flex_basis_smaller_than_content_row.rs @@ -3,49 +3,43 @@ fn flex_basis_smaller_than_content_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_basis: taffy::style::Dimension::Length(50f32), ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_basis: taffy::style::Dimension::Length(50f32), - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/flex_basis_smaller_than_main_dimen_column.rs b/tests/generated/flex_basis_smaller_than_main_dimen_column.rs index fecf6694c..b65b99936 100644 --- a/tests/generated/flex_basis_smaller_than_main_dimen_column.rs +++ b/tests/generated/flex_basis_smaller_than_main_dimen_column.rs @@ -3,36 +3,32 @@ fn flex_basis_smaller_than_main_dimen_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_basis: taffy::style::Dimension::Length(10f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Length(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/flex_basis_smaller_than_main_dimen_row.rs b/tests/generated/flex_basis_smaller_than_main_dimen_row.rs index 655f1b2ea..becaf2224 100644 --- a/tests/generated/flex_basis_smaller_than_main_dimen_row.rs +++ b/tests/generated/flex_basis_smaller_than_main_dimen_row.rs @@ -3,35 +3,31 @@ fn flex_basis_smaller_than_main_dimen_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_basis: taffy::style::Dimension::Length(10f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Length(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs index cf7b0663f..ed2970865 100644 --- a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs +++ b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs @@ -3,80 +3,70 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(70f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(70f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(0f32), ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(0f32), - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(100f32), - }, + }, + &[node00], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(0f32), ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(0f32), - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs index 7a59b2a4c..71414f673 100644 --- a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs +++ b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs @@ -3,80 +3,70 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(70f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(70f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(0f32), ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(0f32), - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(100f32), - }, + }, + &[node00], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(0f32), ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(0f32), - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs index 7b6079d04..eb1343388 100644 --- a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs +++ b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs @@ -3,72 +3,64 @@ fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(70f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(70f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(0f32), ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(0f32), - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(100f32), - }, + }, + &[node00], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(0f32), ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(0f32), - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node10], + ); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node, 90f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs index c2618c00b..a538f7724 100644 --- a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs +++ b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs @@ -3,80 +3,70 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(70f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(70f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(0f32), ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(0f32), - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(100f32), - }, + }, + &[node00], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(0f32), ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(0f32), - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/flex_basis_unconstraint_column.rs b/tests/generated/flex_basis_unconstraint_column.rs index 3e2415a4a..51f69fe7d 100644 --- a/tests/generated/flex_basis_unconstraint_column.rs +++ b/tests/generated/flex_basis_unconstraint_column.rs @@ -3,29 +3,25 @@ fn flex_basis_unconstraint_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_basis: taffy::style::Dimension::Length(50f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Length(50f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/flex_basis_unconstraint_row.rs b/tests/generated/flex_basis_unconstraint_row.rs index e87017d21..322c9eb0b 100644 --- a/tests/generated/flex_basis_unconstraint_row.rs +++ b/tests/generated/flex_basis_unconstraint_row.rs @@ -3,24 +3,22 @@ fn flex_basis_unconstraint_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_basis: taffy::style::Dimension::Length(50f32), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Length(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/flex_basis_zero_undefined_main_size.rs b/tests/generated/flex_basis_zero_undefined_main_size.rs index 874bc5be0..62dc0e926 100644 --- a/tests/generated/flex_basis_zero_undefined_main_size.rs +++ b/tests/generated/flex_basis_zero_undefined_main_size.rs @@ -3,41 +3,37 @@ fn flex_basis_zero_undefined_main_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(50f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_basis: taffy::style::Dimension::Length(0f32), ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_basis: taffy::style::Dimension::Length(0f32), - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00], + ); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/flex_column_relative_all_sides.rs b/tests/generated/flex_column_relative_all_sides.rs index 1945191ab..ff577a991 100644 --- a/tests/generated/flex_column_relative_all_sides.rs +++ b/tests/generated/flex_column_relative_all_sides.rs @@ -3,41 +3,37 @@ fn flex_column_relative_all_sides() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/flex_direction_column.rs b/tests/generated/flex_direction_column.rs index c71f15a77..dbaf516c0 100644 --- a/tests/generated/flex_direction_column.rs +++ b/tests/generated/flex_direction_column.rs @@ -3,57 +3,49 @@ fn flex_direction_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/flex_direction_column_no_height.rs b/tests/generated/flex_direction_column_no_height.rs index 63589920c..b59e27519 100644 --- a/tests/generated/flex_direction_column_no_height.rs +++ b/tests/generated/flex_direction_column_no_height.rs @@ -3,54 +3,46 @@ fn flex_direction_column_no_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/flex_direction_column_reverse.rs b/tests/generated/flex_direction_column_reverse.rs index 7f1e5e880..89d834f72 100644 --- a/tests/generated/flex_direction_column_reverse.rs +++ b/tests/generated/flex_direction_column_reverse.rs @@ -3,57 +3,49 @@ fn flex_direction_column_reverse() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::ColumnReverse, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::ColumnReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/flex_direction_column_reverse_no_height.rs b/tests/generated/flex_direction_column_reverse_no_height.rs index 7b31efee8..521549453 100644 --- a/tests/generated/flex_direction_column_reverse_no_height.rs +++ b/tests/generated/flex_direction_column_reverse_no_height.rs @@ -3,54 +3,46 @@ fn flex_direction_column_reverse_no_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::ColumnReverse, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::ColumnReverse, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/flex_direction_row.rs b/tests/generated/flex_direction_row.rs index 227bc611b..f2ebcdab4 100644 --- a/tests/generated/flex_direction_row.rs +++ b/tests/generated/flex_direction_row.rs @@ -3,56 +3,48 @@ fn flex_direction_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); diff --git a/tests/generated/flex_direction_row_no_width.rs b/tests/generated/flex_direction_row_no_width.rs index ce7a1bc8f..71e0dd281 100644 --- a/tests/generated/flex_direction_row_no_width.rs +++ b/tests/generated/flex_direction_row_no_width.rs @@ -3,53 +3,45 @@ fn flex_direction_row_no_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); diff --git a/tests/generated/flex_direction_row_reverse.rs b/tests/generated/flex_direction_row_reverse.rs index 6f17941b4..167c791f6 100644 --- a/tests/generated/flex_direction_row_reverse.rs +++ b/tests/generated/flex_direction_row_reverse.rs @@ -3,57 +3,49 @@ fn flex_direction_row_reverse() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::RowReverse, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::RowReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node0, 90f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); diff --git a/tests/generated/flex_grow_child.rs b/tests/generated/flex_grow_child.rs index 4b6aa5373..cfc2e351a 100644 --- a/tests/generated/flex_grow_child.rs +++ b/tests/generated/flex_grow_child.rs @@ -3,25 +3,23 @@ fn flex_grow_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(0f32), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(0f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/flex_grow_flex_basis_percent_min_max.rs b/tests/generated/flex_grow_flex_basis_percent_min_max.rs index 7b44548d8..017f39990 100644 --- a/tests/generated/flex_grow_flex_basis_percent_min_max.rs +++ b/tests/generated/flex_grow_flex_basis_percent_min_max.rs @@ -3,53 +3,47 @@ fn flex_grow_flex_basis_percent_min_max() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Length(0f32), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Length(0f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(120f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Percent(0.5f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(120f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); diff --git a/tests/generated/flex_grow_height_maximized.rs b/tests/generated/flex_grow_height_maximized.rs index 2273ab77f..bc9a279b1 100644 --- a/tests/generated/flex_grow_height_maximized.rs +++ b/tests/generated/flex_grow_height_maximized.rs @@ -3,64 +3,56 @@ fn flex_grow_height_maximized() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(200f32), + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(200f32), + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(500f32) }, ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(500f32) }, - ..Default::default() - }, - &[node00, node01], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(500f32), - }, - ..Default::default() + }, + &[node00, node01], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(500f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node0, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node00, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node01, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node01, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); diff --git a/tests/generated/flex_grow_in_at_most_container.rs b/tests/generated/flex_grow_in_at_most_container.rs index 1e642c59b..1bba48082 100644 --- a/tests/generated/flex_grow_in_at_most_container.rs +++ b/tests/generated/flex_grow_in_at_most_container.rs @@ -3,42 +3,38 @@ fn flex_grow_in_at_most_container() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(0f32), - ..Default::default() - }) - .unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::FlexStart), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node00 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(0f32), + ..Default::default() + }); + let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::FlexStart), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/flex_grow_less_than_factor_one.rs b/tests/generated/flex_grow_less_than_factor_one.rs index efb87d3a7..965a0cfc6 100644 --- a/tests/generated/flex_grow_less_than_factor_one.rs +++ b/tests/generated/flex_grow_less_than_factor_one.rs @@ -3,50 +3,44 @@ fn flex_grow_less_than_factor_one() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 0.2f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Length(40f32), - ..Default::default() - }) - .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { flex_grow: 0.2f32, flex_shrink: 0f32, ..Default::default() }).unwrap(); - let node2 = - taffy.new_leaf(taffy::style::Style { flex_grow: 0.4f32, flex_shrink: 0f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(500f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 0.2f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Length(40f32), + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 0.2f32, flex_shrink: 0f32, ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { flex_grow: 0.4f32, flex_shrink: 0f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(500f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 132f32, "width of node {:?}. Expected {}. Actual {}", node0, 132f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 92f32, "width of node {:?}. Expected {}. Actual {}", node1, 92f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node1, 200f32, size.height); assert_eq!(location.x, 132f32, "x of node {:?}. Expected {}. Actual {}", node1, 132f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 184f32, "width of node {:?}. Expected {}. Actual {}", node2, 184f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node2, 200f32, size.height); assert_eq!(location.x, 224f32, "x of node {:?}. Expected {}. Actual {}", node2, 224f32, location.x); diff --git a/tests/generated/flex_grow_root_minimized.rs b/tests/generated/flex_grow_root_minimized.rs index 11a340eb0..951bacf48 100644 --- a/tests/generated/flex_grow_root_minimized.rs +++ b/tests/generated/flex_grow_root_minimized.rs @@ -3,63 +3,55 @@ fn flex_grow_root_minimized() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(200f32), + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(200f32), + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(500f32) }, ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + }, + &[node00, node01], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(500f32) }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(500f32) }, - ..Default::default() - }, - &[node00, node01], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(500f32) }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node0, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node01, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node01, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); diff --git a/tests/generated/flex_grow_shrink_at_most.rs b/tests/generated/flex_grow_shrink_at_most.rs index 5e5717e11..66ab3d148 100644 --- a/tests/generated/flex_grow_shrink_at_most.rs +++ b/tests/generated/flex_grow_shrink_at_most.rs @@ -3,36 +3,33 @@ fn flex_grow_shrink_at_most() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = - taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node00 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }); + let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/flex_grow_to_min.rs b/tests/generated/flex_grow_to_min.rs index 1a9679d81..7e957a18e 100644 --- a/tests/generated/flex_grow_to_min.rs +++ b/tests/generated/flex_grow_to_min.rs @@ -3,41 +3,36 @@ fn flex_grow_to_min() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = - taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(500f32) }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(500f32) }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/flex_grow_within_constrained_max_column.rs b/tests/generated/flex_grow_within_constrained_max_column.rs index efe8d96d1..ee62a87f2 100644 --- a/tests/generated/flex_grow_within_constrained_max_column.rs +++ b/tests/generated/flex_grow_within_constrained_max_column.rs @@ -3,45 +3,39 @@ fn flex_grow_within_constrained_max_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Length(100f32), + let node0 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Length(100f32), + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node1, 33f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/flex_grow_within_constrained_max_row.rs b/tests/generated/flex_grow_within_constrained_max_row.rs index 91a8f01e3..49a464bbd 100644 --- a/tests/generated/flex_grow_within_constrained_max_row.rs +++ b/tests/generated/flex_grow_within_constrained_max_row.rs @@ -3,59 +3,51 @@ fn flex_grow_within_constrained_max_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Length(100f32), + let node00 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Length(100f32), + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + }, + &[node00, node01], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node00, node01], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 67f32, "width of node {:?}. Expected {}. Actual {}", node00, 67f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node01, 33f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node01, 100f32, size.height); assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node01, 67f32, location.x); diff --git a/tests/generated/flex_grow_within_constrained_max_width.rs b/tests/generated/flex_grow_within_constrained_max_width.rs index d70cf998e..082508ca7 100644 --- a/tests/generated/flex_grow_within_constrained_max_width.rs +++ b/tests/generated/flex_grow_within_constrained_max_width.rs @@ -3,50 +3,44 @@ fn flex_grow_within_constrained_max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + let node00 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(300f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(300f32), height: auto() }, - ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node00, 200f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/flex_grow_within_constrained_min_column.rs b/tests/generated/flex_grow_within_constrained_min_column.rs index 2c8b71a42..539b1a8c7 100644 --- a/tests/generated/flex_grow_within_constrained_min_column.rs +++ b/tests/generated/flex_grow_within_constrained_min_column.rs @@ -3,38 +3,34 @@ fn flex_grow_within_constrained_min_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/flex_grow_within_constrained_min_max_column.rs b/tests/generated/flex_grow_within_constrained_min_max_column.rs index 13d381256..39074d501 100644 --- a/tests/generated/flex_grow_within_constrained_min_max_column.rs +++ b/tests/generated/flex_grow_within_constrained_min_max_column.rs @@ -3,39 +3,35 @@ fn flex_grow_within_constrained_min_max_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/flex_grow_within_constrained_min_row.rs b/tests/generated/flex_grow_within_constrained_min_row.rs index 6a3ece6e6..8c256f0ef 100644 --- a/tests/generated/flex_grow_within_constrained_min_row.rs +++ b/tests/generated/flex_grow_within_constrained_min_row.rs @@ -3,38 +3,34 @@ fn flex_grow_within_constrained_min_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); diff --git a/tests/generated/flex_grow_within_max_width.rs b/tests/generated/flex_grow_within_max_width.rs index e61c740d2..b0aba7dee 100644 --- a/tests/generated/flex_grow_within_max_width.rs +++ b/tests/generated/flex_grow_within_max_width.rs @@ -3,50 +3,44 @@ fn flex_grow_within_max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + let node00 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/flex_root_ignored.rs b/tests/generated/flex_root_ignored.rs index af9c4140e..8e1f2006a 100644 --- a/tests/generated/flex_root_ignored.rs +++ b/tests/generated/flex_root_ignored.rs @@ -3,46 +3,40 @@ fn flex_root_ignored() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(200f32), + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(200f32), + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(500f32) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(500f32) }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/flex_row_relative_all_sides.rs b/tests/generated/flex_row_relative_all_sides.rs index 108e13f1c..af029f7be 100644 --- a/tests/generated/flex_row_relative_all_sides.rs +++ b/tests/generated/flex_row_relative_all_sides.rs @@ -3,40 +3,36 @@ fn flex_row_relative_all_sides() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/flex_shrink_by_outer_margin_with_max_size.rs b/tests/generated/flex_shrink_by_outer_margin_with_max_size.rs index 067beaaab..a09423b59 100644 --- a/tests/generated/flex_shrink_by_outer_margin_with_max_size.rs +++ b/tests/generated/flex_shrink_by_outer_margin_with_max_size.rs @@ -3,42 +3,38 @@ fn flex_shrink_by_outer_margin_with_max_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(100f32), - bottom: zero(), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(100f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(80f32) }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(80f32) }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs b/tests/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs index 6bcfb9a00..6c9096598 100644 --- a/tests/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs +++ b/tests/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs @@ -3,55 +3,49 @@ fn flex_shrink_flex_grow_child_flex_shrink_other_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 0f32, - flex_shrink: 1f32, + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(500f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(500f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Length(500f32), - height: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(500f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(500f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(500f32), - height: taffy::style::Dimension::Length(500f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node0, 250f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node1, 250f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node1, 250f32, location.x); diff --git a/tests/generated/flex_shrink_flex_grow_row.rs b/tests/generated/flex_shrink_flex_grow_row.rs index 86c514b89..e3abfb008 100644 --- a/tests/generated/flex_shrink_flex_grow_row.rs +++ b/tests/generated/flex_shrink_flex_grow_row.rs @@ -3,55 +3,49 @@ fn flex_shrink_flex_grow_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 0f32, - flex_shrink: 1f32, + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(500f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(500f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Length(500f32), - height: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(500f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 0f32, - flex_shrink: 1f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(500f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(500f32), - height: taffy::style::Dimension::Length(500f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node0, 250f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node1, 250f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node1, 250f32, location.x); diff --git a/tests/generated/flex_shrink_to_zero.rs b/tests/generated/flex_shrink_to_zero.rs index 2e9429204..9677e23bb 100644 --- a/tests/generated/flex_shrink_to_zero.rs +++ b/tests/generated/flex_shrink_to_zero.rs @@ -3,65 +3,57 @@ fn flex_shrink_to_zero() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(75f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 1f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(75f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 75f32, "width of node {:?}. Expected {}. Actual {}", node, 75f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); diff --git a/tests/generated/flex_wrap_align_stretch_fits_one_row.rs b/tests/generated/flex_wrap_align_stretch_fits_one_row.rs index 43d8a3684..c76853529 100644 --- a/tests/generated/flex_wrap_align_stretch_fits_one_row.rs +++ b/tests/generated/flex_wrap_align_stretch_fits_one_row.rs @@ -3,46 +3,40 @@ fn flex_wrap_align_stretch_fits_one_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); diff --git a/tests/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs b/tests/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs index 369c6b7f4..9e46d0779 100644 --- a/tests/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs +++ b/tests/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs @@ -3,47 +3,41 @@ fn flex_wrap_children_with_min_main_overriding_flex_basis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_basis: taffy::style::Dimension::Length(50f32), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(55f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Length(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(55f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Length(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(55f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_basis: taffy::style::Dimension::Length(50f32), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(55f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node0, 55f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node1, 55f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/flex_wrap_wrap_to_child_height.rs b/tests/generated/flex_wrap_wrap_to_child_height.rs index 40b9b9173..e5d4fcb7a 100644 --- a/tests/generated/flex_wrap_wrap_to_child_height.rs +++ b/tests/generated/flex_wrap_wrap_to_child_height.rs @@ -3,75 +3,65 @@ fn flex_wrap_wrap_to_child_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: Some(taffy::style::AlignItems::FlexStart), - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::FlexStart), ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00], + ); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node000, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node000, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/gap_column_gap_child_margins.rs b/tests/generated/gap_column_gap_child_margins.rs index 04f206835..e45e802c9 100644 --- a/tests/generated/gap_column_gap_child_margins.rs +++ b/tests/generated/gap_column_gap_child_margins.rs @@ -3,81 +3,73 @@ fn gap_column_gap_child_margins() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(2f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: zero(), - bottom: zero(), + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(2f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(15f32), + right: taffy::style::LengthPercentageAuto::Length(15f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(80f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(15f32), - right: taffy::style::LengthPercentageAuto::Length(15f32), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(80f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node0, 2f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node1, 2f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 26f32, "x of node {:?}. Expected {}. Actual {}", node1, 26f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node2, 2f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 63f32, "x of node {:?}. Expected {}. Actual {}", node2, 63f32, location.x); diff --git a/tests/generated/gap_column_gap_determines_parent_width.rs b/tests/generated/gap_column_gap_determines_parent_width.rs index 2fc2c06cc..8c09d18a3 100644 --- a/tests/generated/gap_column_gap_determines_parent_width.rs +++ b/tests/generated/gap_column_gap_determines_parent_width.rs @@ -3,55 +3,47 @@ fn gap_column_gap_determines_parent_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(30f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Stretch), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(30f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Stretch), - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); diff --git a/tests/generated/gap_column_gap_flexible.rs b/tests/generated/gap_column_gap_flexible.rs index 7d71fd7a1..2e823480e 100644 --- a/tests/generated/gap_column_gap_flexible.rs +++ b/tests/generated/gap_column_gap_flexible.rs @@ -3,66 +3,58 @@ fn gap_column_gap_flexible() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(10f32), - height: taffy::style::LengthPercentage::Length(20f32), - }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(80f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(10f32), + height: taffy::style::LengthPercentage::Length(20f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(80f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); diff --git a/tests/generated/gap_column_gap_flexible_undefined_parent.rs b/tests/generated/gap_column_gap_flexible_undefined_parent.rs index 909aed37f..88de5890e 100644 --- a/tests/generated/gap_column_gap_flexible_undefined_parent.rs +++ b/tests/generated/gap_column_gap_flexible_undefined_parent.rs @@ -3,63 +3,55 @@ fn gap_column_gap_flexible_undefined_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(10f32), - height: taffy::style::LengthPercentage::Length(20f32), - }, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(10f32), + height: taffy::style::LengthPercentage::Length(20f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); diff --git a/tests/generated/gap_column_gap_inflexible.rs b/tests/generated/gap_column_gap_inflexible.rs index 08b5ba6f2..49efe8388 100644 --- a/tests/generated/gap_column_gap_inflexible.rs +++ b/tests/generated/gap_column_gap_inflexible.rs @@ -3,57 +3,49 @@ fn gap_column_gap_inflexible() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(80f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(80f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); diff --git a/tests/generated/gap_column_gap_inflexible_undefined_parent.rs b/tests/generated/gap_column_gap_inflexible_undefined_parent.rs index 6f11c7650..97be1c9bf 100644 --- a/tests/generated/gap_column_gap_inflexible_undefined_parent.rs +++ b/tests/generated/gap_column_gap_inflexible_undefined_parent.rs @@ -3,54 +3,46 @@ fn gap_column_gap_inflexible_undefined_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); diff --git a/tests/generated/gap_column_gap_justify_center.rs b/tests/generated/gap_column_gap_justify_center.rs index af0112ea4..e5bf5947f 100644 --- a/tests/generated/gap_column_gap_justify_center.rs +++ b/tests/generated/gap_column_gap_justify_center.rs @@ -3,58 +3,50 @@ fn gap_column_gap_justify_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::Center), - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Center), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); diff --git a/tests/generated/gap_column_gap_justify_flex_end.rs b/tests/generated/gap_column_gap_justify_flex_end.rs index 3e622ea08..411ed800c 100644 --- a/tests/generated/gap_column_gap_justify_flex_end.rs +++ b/tests/generated/gap_column_gap_justify_flex_end.rs @@ -3,58 +3,50 @@ fn gap_column_gap_justify_flex_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::FlexEnd), - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::FlexEnd), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); diff --git a/tests/generated/gap_column_gap_justify_flex_start.rs b/tests/generated/gap_column_gap_justify_flex_start.rs index 0f4626d0e..cd523c802 100644 --- a/tests/generated/gap_column_gap_justify_flex_start.rs +++ b/tests/generated/gap_column_gap_justify_flex_start.rs @@ -3,58 +3,50 @@ fn gap_column_gap_justify_flex_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::FlexStart), - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::FlexStart), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); diff --git a/tests/generated/gap_column_gap_justify_space_around.rs b/tests/generated/gap_column_gap_justify_space_around.rs index de4fb0774..b0aa04b7b 100644 --- a/tests/generated/gap_column_gap_justify_space_around.rs +++ b/tests/generated/gap_column_gap_justify_space_around.rs @@ -3,58 +3,50 @@ fn gap_column_gap_justify_space_around() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::SpaceAround), - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::SpaceAround), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 3f32, "x of node {:?}. Expected {}. Actual {}", node0, 3f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 77f32, "x of node {:?}. Expected {}. Actual {}", node2, 77f32, location.x); diff --git a/tests/generated/gap_column_gap_justify_space_between.rs b/tests/generated/gap_column_gap_justify_space_between.rs index 361d08362..a32636b34 100644 --- a/tests/generated/gap_column_gap_justify_space_between.rs +++ b/tests/generated/gap_column_gap_justify_space_between.rs @@ -3,58 +3,50 @@ fn gap_column_gap_justify_space_between() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::SpaceBetween), - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); diff --git a/tests/generated/gap_column_gap_justify_space_evenly.rs b/tests/generated/gap_column_gap_justify_space_evenly.rs index 461af1b63..96c0ec7e6 100644 --- a/tests/generated/gap_column_gap_justify_space_evenly.rs +++ b/tests/generated/gap_column_gap_justify_space_evenly.rs @@ -3,58 +3,50 @@ fn gap_column_gap_justify_space_evenly() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node2, 75f32, location.x); diff --git a/tests/generated/gap_column_gap_mixed_flexible.rs b/tests/generated/gap_column_gap_mixed_flexible.rs index f2f033028..3c1e32dac 100644 --- a/tests/generated/gap_column_gap_mixed_flexible.rs +++ b/tests/generated/gap_column_gap_mixed_flexible.rs @@ -3,59 +3,51 @@ fn gap_column_gap_mixed_flexible() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(80f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(10f32), height: zero() }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(80f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); diff --git a/tests/generated/gap_column_gap_percentage_cyclic_partially_shrinkable.rs b/tests/generated/gap_column_gap_percentage_cyclic_partially_shrinkable.rs index 5ceb39aad..f09e53d95 100644 --- a/tests/generated/gap_column_gap_percentage_cyclic_partially_shrinkable.rs +++ b/tests/generated/gap_column_gap_percentage_cyclic_partially_shrinkable.rs @@ -3,64 +3,56 @@ fn gap_column_gap_percentage_cyclic_partially_shrinkable() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(40f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.5f32), height: zero() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.5f32), height: zero() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); diff --git a/tests/generated/gap_column_gap_percentage_cyclic_shrinkable.rs b/tests/generated/gap_column_gap_percentage_cyclic_shrinkable.rs index 3fbce7894..859087349 100644 --- a/tests/generated/gap_column_gap_percentage_cyclic_shrinkable.rs +++ b/tests/generated/gap_column_gap_percentage_cyclic_shrinkable.rs @@ -3,62 +3,54 @@ fn gap_column_gap_percentage_cyclic_shrinkable() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(40f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node0, 12f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node1, 12f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 24f32, "x of node {:?}. Expected {}. Actual {}", node1, 24f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node2, 12f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node2, 48f32, location.x); diff --git a/tests/generated/gap_column_gap_percentage_cyclic_unshrinkable.rs b/tests/generated/gap_column_gap_percentage_cyclic_unshrinkable.rs index f4fdb5aba..b36d77e46 100644 --- a/tests/generated/gap_column_gap_percentage_cyclic_unshrinkable.rs +++ b/tests/generated/gap_column_gap_percentage_cyclic_unshrinkable.rs @@ -3,65 +3,57 @@ fn gap_column_gap_percentage_cyclic_unshrinkable() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(40f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node1, 32f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 64f32, "x of node {:?}. Expected {}. Actual {}", node2, 64f32, location.x); diff --git a/tests/generated/gap_column_gap_percentage_flexible.rs b/tests/generated/gap_column_gap_percentage_flexible.rs index 3fa8247e7..026c90059 100644 --- a/tests/generated/gap_column_gap_percentage_flexible.rs +++ b/tests/generated/gap_column_gap_percentage_flexible.rs @@ -3,66 +3,58 @@ fn gap_column_gap_percentage_flexible() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Percent(0.1f32), - height: taffy::style::LengthPercentage::Length(20f32), - }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Percent(0.1f32), + height: taffy::style::LengthPercentage::Length(20f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 27f32, "width of node {:?}. Expected {}. Actual {}", node0, 27f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 26f32, "width of node {:?}. Expected {}. Actual {}", node1, 26f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 37f32, "x of node {:?}. Expected {}. Actual {}", node1, 37f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 27f32, "width of node {:?}. Expected {}. Actual {}", node2, 27f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 73f32, "x of node {:?}. Expected {}. Actual {}", node2, 73f32, location.x); diff --git a/tests/generated/gap_column_gap_percentage_flexible_with_padding.rs b/tests/generated/gap_column_gap_percentage_flexible_with_padding.rs index e42c8e967..c8110ff08 100644 --- a/tests/generated/gap_column_gap_percentage_flexible_with_padding.rs +++ b/tests/generated/gap_column_gap_percentage_flexible_with_padding.rs @@ -3,72 +3,64 @@ fn gap_column_gap_percentage_flexible_with_padding() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Percent(0.1f32), - height: taffy::style::LengthPercentage::Length(20f32), - }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Percent(0.1f32), + height: taffy::style::LengthPercentage::Length(20f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), + }, + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 21f32, "width of node {:?}. Expected {}. Actual {}", node0, 21f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node1, 22f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height); assert_eq!(location.x, 39f32, "x of node {:?}. Expected {}. Actual {}", node1, 39f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 21f32, "width of node {:?}. Expected {}. Actual {}", node2, 21f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node2, 80f32, size.height); assert_eq!(location.x, 69f32, "x of node {:?}. Expected {}. Actual {}", node2, 69f32, location.x); diff --git a/tests/generated/gap_column_gap_percentage_inflexible.rs b/tests/generated/gap_column_gap_percentage_inflexible.rs index 4116537c9..b38403bc5 100644 --- a/tests/generated/gap_column_gap_percentage_inflexible.rs +++ b/tests/generated/gap_column_gap_percentage_inflexible.rs @@ -3,57 +3,49 @@ fn gap_column_gap_percentage_inflexible() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); diff --git a/tests/generated/gap_column_gap_row_gap_wrapping.rs b/tests/generated/gap_column_gap_row_gap_wrapping.rs index 5b7a8a105..4be799f92 100644 --- a/tests/generated/gap_column_gap_row_gap_wrapping.rs +++ b/tests/generated/gap_column_gap_row_gap_wrapping.rs @@ -3,151 +3,131 @@ fn gap_column_gap_row_gap_wrapping() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node6 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node7 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node8 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(10f32), + height: taffy::style::LengthPercentage::Length(20f32), }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(80f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node6 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node7 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node8 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(10f32), - height: taffy::style::LengthPercentage::Length(20f32), - }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(80f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node7, 30f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node8, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); diff --git a/tests/generated/gap_column_gap_wrap_align_center.rs b/tests/generated/gap_column_gap_wrap_align_center.rs index 1085c91e5..a1e6b1b86 100644 --- a/tests/generated/gap_column_gap_wrap_align_center.rs +++ b/tests/generated/gap_column_gap_wrap_align_center.rs @@ -3,113 +3,99 @@ fn gap_column_gap_wrap_align_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::Center), + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(10f32), + height: taffy::style::LengthPercentage::Length(20f32), }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::Center), - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(10f32), - height: taffy::style::LengthPercentage::Length(20f32), - }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node4, 60f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); diff --git a/tests/generated/gap_column_gap_wrap_align_flex_end.rs b/tests/generated/gap_column_gap_wrap_align_flex_end.rs index df6bf0dee..827b8b152 100644 --- a/tests/generated/gap_column_gap_wrap_align_flex_end.rs +++ b/tests/generated/gap_column_gap_wrap_align_flex_end.rs @@ -3,113 +3,99 @@ fn gap_column_gap_wrap_align_flex_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::FlexEnd), + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(10f32), + height: taffy::style::LengthPercentage::Length(20f32), }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::FlexEnd), - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(10f32), - height: taffy::style::LengthPercentage::Length(20f32), - }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); diff --git a/tests/generated/gap_column_gap_wrap_align_flex_start.rs b/tests/generated/gap_column_gap_wrap_align_flex_start.rs index 09de805bd..544f49fd9 100644 --- a/tests/generated/gap_column_gap_wrap_align_flex_start.rs +++ b/tests/generated/gap_column_gap_wrap_align_flex_start.rs @@ -3,113 +3,99 @@ fn gap_column_gap_wrap_align_flex_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::FlexStart), + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(10f32), + height: taffy::style::LengthPercentage::Length(20f32), }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::FlexStart), - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(10f32), - height: taffy::style::LengthPercentage::Length(20f32), - }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); diff --git a/tests/generated/gap_column_gap_wrap_align_space_around.rs b/tests/generated/gap_column_gap_wrap_align_space_around.rs index 7013abbc7..afedc5373 100644 --- a/tests/generated/gap_column_gap_wrap_align_space_around.rs +++ b/tests/generated/gap_column_gap_wrap_align_space_around.rs @@ -3,113 +3,99 @@ fn gap_column_gap_wrap_align_space_around() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::SpaceAround), + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(10f32), + height: taffy::style::LengthPercentage::Length(20f32), }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::SpaceAround), - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(10f32), - height: taffy::style::LengthPercentage::Length(20f32), - }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node3, 70f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node4, 70f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); diff --git a/tests/generated/gap_column_gap_wrap_align_space_between.rs b/tests/generated/gap_column_gap_wrap_align_space_between.rs index d035988e4..db7d4245d 100644 --- a/tests/generated/gap_column_gap_wrap_align_space_between.rs +++ b/tests/generated/gap_column_gap_wrap_align_space_between.rs @@ -3,113 +3,99 @@ fn gap_column_gap_wrap_align_space_between() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::SpaceBetween), + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(10f32), + height: taffy::style::LengthPercentage::Length(20f32), }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::SpaceBetween), - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(10f32), - height: taffy::style::LengthPercentage::Length(20f32), - }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); diff --git a/tests/generated/gap_column_gap_wrap_align_stretch.rs b/tests/generated/gap_column_gap_wrap_align_stretch.rs index d16d66efd..2cd6e5b40 100644 --- a/tests/generated/gap_column_gap_wrap_align_stretch.rs +++ b/tests/generated/gap_column_gap_wrap_align_stretch.rs @@ -3,86 +3,74 @@ fn gap_column_gap_wrap_align_stretch() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: Some(taffy::style::AlignContent::Stretch), - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(5f32), height: zero() }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(300f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_content: Some(taffy::style::AlignContent::Stretch), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(5f32), height: zero() }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(300f32), + height: taffy::style::Dimension::Length(300f32), }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node, 300f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node0, 71f32, size.width); assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node0, 150f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node1, 72f32, size.width); assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node1, 150f32, size.height); assert_eq!(location.x, 76f32, "x of node {:?}. Expected {}. Actual {}", node1, 76f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node2, 71f32, size.width); assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node2, 150f32, size.height); assert_eq!(location.x, 153f32, "x of node {:?}. Expected {}. Actual {}", node2, 153f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node3, 71f32, size.width); assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node3, 150f32, size.height); assert_eq!(location.x, 229f32, "x of node {:?}. Expected {}. Actual {}", node3, 229f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node4, 300f32, size.width); assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node4, 150f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); diff --git a/tests/generated/gap_column_row_gap_wrapping.rs b/tests/generated/gap_column_row_gap_wrapping.rs index 770954384..de41f41b2 100644 --- a/tests/generated/gap_column_row_gap_wrapping.rs +++ b/tests/generated/gap_column_row_gap_wrapping.rs @@ -3,151 +3,131 @@ fn gap_column_row_gap_wrapping() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node6 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node7 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node8 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(10f32), + height: taffy::style::LengthPercentage::Length(20f32), }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(80f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node6 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node7 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node8 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(10f32), - height: taffy::style::LengthPercentage::Length(20f32), - }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(80f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node7, 30f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node8, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); diff --git a/tests/generated/gap_row_gap_align_items_end.rs b/tests/generated/gap_row_gap_align_items_end.rs index 72acc9795..801ee3f1a 100644 --- a/tests/generated/gap_row_gap_align_items_end.rs +++ b/tests/generated/gap_row_gap_align_items_end.rs @@ -3,95 +3,81 @@ fn gap_row_gap_align_items_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: Some(taffy::style::AlignItems::FlexEnd), - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(10f32), - height: taffy::style::LengthPercentage::Length(20f32), - }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::FlexEnd), + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(10f32), + height: taffy::style::LengthPercentage::Length(20f32), }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node1, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node3, 200f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node4, 200f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); diff --git a/tests/generated/gap_row_gap_align_items_stretch.rs b/tests/generated/gap_row_gap_align_items_stretch.rs index 553752633..9f7a16980 100644 --- a/tests/generated/gap_row_gap_align_items_stretch.rs +++ b/tests/generated/gap_row_gap_align_items_stretch.rs @@ -3,96 +3,82 @@ fn gap_row_gap_align_items_stretch() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: Some(taffy::style::AlignItems::Stretch), - align_content: Some(taffy::style::AlignContent::Stretch), - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(10f32), - height: taffy::style::LengthPercentage::Length(20f32), - }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::Stretch), + align_content: Some(taffy::style::AlignContent::Stretch), + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(10f32), + height: taffy::style::LengthPercentage::Length(20f32), }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node0, 90f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node1, 90f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node2, 90f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node3, 90f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 110f32, "y of node {:?}. Expected {}. Actual {}", node3, 110f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node4, 90f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); assert_eq!(location.y, 110f32, "y of node {:?}. Expected {}. Actual {}", node4, 110f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node5, 90f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); diff --git a/tests/generated/gap_row_gap_column_child_margins.rs b/tests/generated/gap_row_gap_column_child_margins.rs index 7b3574fb1..f48b10269 100644 --- a/tests/generated/gap_row_gap_column_child_margins.rs +++ b/tests/generated/gap_row_gap_column_child_margins.rs @@ -3,82 +3,74 @@ fn gap_row_gap_column_child_margins() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(2f32), - bottom: taffy::style::LengthPercentageAuto::Length(2f32), + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(2f32), + bottom: taffy::style::LengthPercentageAuto::Length(2f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(15f32), + bottom: taffy::style::LengthPercentageAuto::Length(15f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + gap: taffy::geometry::Size { width: zero(), height: taffy::style::LengthPercentage::Length(10f32) }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(15f32), - bottom: taffy::style::LengthPercentageAuto::Length(15f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - gap: taffy::geometry::Size { width: zero(), height: taffy::style::LengthPercentage::Length(10f32) }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node0, 42f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node1, 42f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 66f32, "y of node {:?}. Expected {}. Actual {}", node1, 66f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node2, 42f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/gap_row_gap_determines_parent_height.rs b/tests/generated/gap_row_gap_determines_parent_height.rs index c78644229..8a0989df6 100644 --- a/tests/generated/gap_row_gap_determines_parent_height.rs +++ b/tests/generated/gap_row_gap_determines_parent_height.rs @@ -3,56 +3,48 @@ fn gap_row_gap_determines_parent_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(30f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Stretch), + gap: taffy::geometry::Size { width: zero(), height: taffy::style::LengthPercentage::Length(10f32) }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(30f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Stretch), - gap: taffy::geometry::Size { width: zero(), height: taffy::style::LengthPercentage::Length(10f32) }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/gap_row_gap_percentage_wrapping.rs b/tests/generated/gap_row_gap_percentage_wrapping.rs index 79cad66c7..21d1f2a56 100644 --- a/tests/generated/gap_row_gap_percentage_wrapping.rs +++ b/tests/generated/gap_row_gap_percentage_wrapping.rs @@ -3,151 +3,131 @@ fn gap_row_gap_percentage_wrapping() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node6 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node7 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node8 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(10f32), + height: taffy::style::LengthPercentage::Percent(0.1f32), }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(80f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node6 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node7 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node8 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(10f32), - height: taffy::style::LengthPercentage::Percent(0.1f32), - }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(80f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node3, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node4, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node5, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node7, 30f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node8, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); diff --git a/tests/generated/gap_row_gap_row_wrap_child_margins.rs b/tests/generated/gap_row_gap_row_wrap_child_margins.rs index 438d315b1..7b2888e3a 100644 --- a/tests/generated/gap_row_gap_row_wrap_child_margins.rs +++ b/tests/generated/gap_row_gap_row_wrap_child_margins.rs @@ -3,76 +3,68 @@ fn gap_row_gap_row_wrap_child_margins() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(2f32), - bottom: taffy::style::LengthPercentageAuto::Length(2f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(2f32), + bottom: taffy::style::LengthPercentageAuto::Length(2f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(15f32), + bottom: taffy::style::LengthPercentageAuto::Length(15f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + gap: taffy::geometry::Size { width: zero(), height: taffy::style::LengthPercentage::Length(10f32) }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(15f32), - bottom: taffy::style::LengthPercentageAuto::Length(15f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - gap: taffy::geometry::Size { width: zero(), height: taffy::style::LengthPercentage::Length(10f32) }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node0, 42f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node1, 42f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 66f32, "y of node {:?}. Expected {}. Actual {}", node1, 66f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node2, 60f32, size.width); assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node2, 42f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_absolute_align_self_sized_all.rs b/tests/generated/grid_absolute_align_self_sized_all.rs index 39376cb8d..9537f24c6 100644 --- a/tests/generated/grid_absolute_align_self_sized_all.rs +++ b/tests/generated/grid_absolute_align_self_sized_all.rs @@ -3,154 +3,136 @@ fn grid_absolute_align_self_sized_all() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::Start), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node6 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node7 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::End), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::End), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node6 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node7 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node3, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node5, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node6, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x); diff --git a/tests/generated/grid_absolute_column_end.rs b/tests/generated/grid_absolute_column_end.rs index a831377d4..db1120d78 100644 --- a/tests/generated/grid_absolute_column_end.rs +++ b/tests/generated/grid_absolute_column_end.rs @@ -3,46 +3,42 @@ fn grid_absolute_column_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Auto, end: line(1i16) }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(3f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(2f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + grid_column: taffy::geometry::Line { start: taffy::style::GridPlacement::Auto, end: line(1i16) }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(3f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(2f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node0, 33f32, size.width); assert_eq!(size.height, 157f32, "height of node {:?}. Expected {}. Actual {}", node0, 157f32, size.height); assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); diff --git a/tests/generated/grid_absolute_column_start.rs b/tests/generated/grid_absolute_column_start.rs index 39d3596a7..f997ec30b 100644 --- a/tests/generated/grid_absolute_column_start.rs +++ b/tests/generated/grid_absolute_column_start.rs @@ -3,46 +3,42 @@ fn grid_absolute_column_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(3f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(2f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(3f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(2f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 133f32, "width of node {:?}. Expected {}. Actual {}", node0, 133f32, size.width); assert_eq!(size.height, 157f32, "height of node {:?}. Expected {}. Actual {}", node0, 157f32, size.height); assert_eq!(location.x, 44f32, "x of node {:?}. Expected {}. Actual {}", node0, 44f32, location.x); diff --git a/tests/generated/grid_absolute_container_bottom_left.rs b/tests/generated/grid_absolute_container_bottom_left.rs index 7854df8db..be4ae722d 100644 --- a/tests/generated/grid_absolute_container_bottom_left.rs +++ b/tests/generated/grid_absolute_container_bottom_left.rs @@ -3,93 +3,89 @@ fn grid_absolute_container_bottom_left() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: auto(), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node0, 160f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_absolute_container_bottom_left_margin.rs b/tests/generated/grid_absolute_container_bottom_left_margin.rs index 5655d25d7..da5d498ba 100644 --- a/tests/generated/grid_absolute_container_bottom_left_margin.rs +++ b/tests/generated/grid_absolute_container_bottom_left_margin.rs @@ -3,103 +3,99 @@ fn grid_absolute_container_bottom_left_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(3f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: auto(), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(3f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); assert_eq!(location.y, 147f32, "y of node {:?}. Expected {}. Actual {}", node0, 147f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_absolute_container_left_overrides_right.rs b/tests/generated/grid_absolute_container_left_overrides_right.rs index e09a5c830..7bb0b105c 100644 --- a/tests/generated/grid_absolute_container_left_overrides_right.rs +++ b/tests/generated/grid_absolute_container_left_overrides_right.rs @@ -3,94 +3,90 @@ fn grid_absolute_container_left_overrides_right() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: auto(), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_absolute_container_left_right.rs b/tests/generated/grid_absolute_container_left_right.rs index cc666134b..c4fb31e82 100644 --- a/tests/generated/grid_absolute_container_left_right.rs +++ b/tests/generated/grid_absolute_container_left_right.rs @@ -3,93 +3,89 @@ fn grid_absolute_container_left_right() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: auto(), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 173f32, "width of node {:?}. Expected {}. Actual {}", node0, 173f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_absolute_container_left_right_margin.rs b/tests/generated/grid_absolute_container_left_right_margin.rs index 77fa653d6..885286841 100644 --- a/tests/generated/grid_absolute_container_left_right_margin.rs +++ b/tests/generated/grid_absolute_container_left_right_margin.rs @@ -3,99 +3,95 @@ fn grid_absolute_container_left_right_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(3f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: auto(), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(3f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 167f32, "width of node {:?}. Expected {}. Actual {}", node0, 167f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 9f32, "x of node {:?}. Expected {}. Actual {}", node0, 9f32, location.x); assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_absolute_container_negative_position.rs b/tests/generated/grid_absolute_container_negative_position.rs index 1fbb57b5c..2efa21298 100644 --- a/tests/generated/grid_absolute_container_negative_position.rs +++ b/tests/generated/grid_absolute_container_negative_position.rs @@ -3,104 +3,98 @@ fn grid_absolute_container_negative_position() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(-15f32), - top: taffy::style::LengthPercentageAuto::Length(-5f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(-15f32), + top: taffy::style::LengthPercentageAuto::Length(-5f32), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(-35f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(-25f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(-35f32), - right: auto(), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(-25f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 195f32, "x of node {:?}. Expected {}. Actual {}", node0, 195f32, location.x); assert_eq!(location.y, -5f32, "y of node {:?}. Expected {}. Actual {}", node0, -5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, -35f32, "x of node {:?}. Expected {}. Actual {}", node1, -35f32, location.x); assert_eq!(location.y, 185f32, "y of node {:?}. Expected {}. Actual {}", node1, 185f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node4, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node7, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); diff --git a/tests/generated/grid_absolute_container_negative_position_margin.rs b/tests/generated/grid_absolute_container_negative_position_margin.rs index 9fca0efdb..1c8098646 100644 --- a/tests/generated/grid_absolute_container_negative_position_margin.rs +++ b/tests/generated/grid_absolute_container_negative_position_margin.rs @@ -3,116 +3,110 @@ fn grid_absolute_container_negative_position_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(3f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(-15f32), - top: taffy::style::LengthPercentageAuto::Length(-5f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(3f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(-15f32), + top: taffy::style::LengthPercentageAuto::Length(-5f32), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(3f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(-35f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(-25f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(3f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(-35f32), - right: auto(), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(-25f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 193f32, "x of node {:?}. Expected {}. Actual {}", node0, 193f32, location.x); assert_eq!(location.y, -4f32, "y of node {:?}. Expected {}. Actual {}", node0, -4f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, -31f32, "x of node {:?}. Expected {}. Actual {}", node1, -31f32, location.x); assert_eq!(location.y, 182f32, "y of node {:?}. Expected {}. Actual {}", node1, 182f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node4, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node7, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); diff --git a/tests/generated/grid_absolute_container_top_bottom.rs b/tests/generated/grid_absolute_container_top_bottom.rs index 3e21ca8ef..628622164 100644 --- a/tests/generated/grid_absolute_container_top_bottom.rs +++ b/tests/generated/grid_absolute_container_top_bottom.rs @@ -3,93 +3,89 @@ fn grid_absolute_container_top_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(2f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(2f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 153f32, "height of node {:?}. Expected {}. Actual {}", node0, 153f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_absolute_container_top_bottom_margin.rs b/tests/generated/grid_absolute_container_top_bottom_margin.rs index 687f62b22..a8c24fb7f 100644 --- a/tests/generated/grid_absolute_container_top_bottom_margin.rs +++ b/tests/generated/grid_absolute_container_top_bottom_margin.rs @@ -3,99 +3,95 @@ fn grid_absolute_container_top_bottom_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(3f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(2f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(3f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(2f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 149f32, "height of node {:?}. Expected {}. Actual {}", node0, 149f32, size.height); assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0, 3f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_absolute_container_top_right.rs b/tests/generated/grid_absolute_container_top_right.rs index 718a8eea6..ce7928379 100644 --- a/tests/generated/grid_absolute_container_top_right.rs +++ b/tests/generated/grid_absolute_container_top_right.rs @@ -3,93 +3,89 @@ fn grid_absolute_container_top_right() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 180f32, "x of node {:?}. Expected {}. Actual {}", node0, 180f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_absolute_container_top_right_margin.rs b/tests/generated/grid_absolute_container_top_right_margin.rs index e7fe56880..f208b1799 100644 --- a/tests/generated/grid_absolute_container_top_right_margin.rs +++ b/tests/generated/grid_absolute_container_top_right_margin.rs @@ -3,99 +3,95 @@ fn grid_absolute_container_top_right_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(3f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(3f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 178f32, "x of node {:?}. Expected {}. Actual {}", node0, 178f32, location.x); assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_absolute_justify_self_sized_all.rs b/tests/generated/grid_absolute_justify_self_sized_all.rs index 748d52c2d..d16aebe53 100644 --- a/tests/generated/grid_absolute_justify_self_sized_all.rs +++ b/tests/generated/grid_absolute_justify_self_sized_all.rs @@ -3,154 +3,136 @@ fn grid_absolute_justify_self_sized_all() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - justify_self: Some(taffy::style::JustifySelf::Start), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node6 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node7 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - justify_self: Some(taffy::style::JustifySelf::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - justify_self: Some(taffy::style::JustifySelf::End), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - justify_self: Some(taffy::style::JustifySelf::End), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - justify_self: Some(taffy::style::JustifySelf::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - justify_self: Some(taffy::style::JustifySelf::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node6 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - justify_self: Some(taffy::style::JustifySelf::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node7 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - justify_self: Some(taffy::style::JustifySelf::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node3, 60f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node5, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node6, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x); diff --git a/tests/generated/grid_absolute_layout_within_border.rs b/tests/generated/grid_absolute_layout_within_border.rs index 088345321..21ad7945e 100644 --- a/tests/generated/grid_absolute_layout_within_border.rs +++ b/tests/generated/grid_absolute_layout_within_border.rs @@ -3,132 +3,122 @@ fn grid_absolute_layout_within_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: auto(), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: auto(), + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: auto(), + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); diff --git a/tests/generated/grid_absolute_layout_within_border_static.rs b/tests/generated/grid_absolute_layout_within_border_static.rs index f2c9b9c36..07365194d 100644 --- a/tests/generated/grid_absolute_layout_within_border_static.rs +++ b/tests/generated/grid_absolute_layout_within_border_static.rs @@ -3,116 +3,106 @@ fn grid_absolute_layout_within_border_static() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::Start), - justify_self: Some(taffy::style::JustifySelf::Start), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::End), - justify_self: Some(taffy::style::JustifySelf::End), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::Start), - justify_self: Some(taffy::style::JustifySelf::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - align_self: Some(taffy::style::AlignSelf::End), - justify_self: Some(taffy::style::JustifySelf::End), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); diff --git a/tests/generated/grid_absolute_row_end.rs b/tests/generated/grid_absolute_row_end.rs index fea7ed114..07c78481c 100644 --- a/tests/generated/grid_absolute_row_end.rs +++ b/tests/generated/grid_absolute_row_end.rs @@ -3,46 +3,42 @@ fn grid_absolute_row_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - grid_row: taffy::geometry::Line { start: taffy::style::GridPlacement::Auto, end: line(1i16) }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(3f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(2f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + grid_row: taffy::geometry::Line { start: taffy::style::GridPlacement::Auto, end: line(1i16) }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(3f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(2f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 173f32, "width of node {:?}. Expected {}. Actual {}", node0, 173f32, size.width); assert_eq!(size.height, 7f32, "height of node {:?}. Expected {}. Actual {}", node0, 7f32, size.height); assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); diff --git a/tests/generated/grid_absolute_row_start.rs b/tests/generated/grid_absolute_row_start.rs index de6af9370..18147d90f 100644 --- a/tests/generated/grid_absolute_row_start.rs +++ b/tests/generated/grid_absolute_row_start.rs @@ -3,46 +3,42 @@ fn grid_absolute_row_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(3f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(2f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(3f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(2f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 173f32, "width of node {:?}. Expected {}. Actual {}", node0, 173f32, size.width); assert_eq!(size.height, 147f32, "height of node {:?}. Expected {}. Actual {}", node0, 147f32, size.height); assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); diff --git a/tests/generated/grid_absolute_top_overrides_bottom.rs b/tests/generated/grid_absolute_top_overrides_bottom.rs index 11c146828..175b7d5c6 100644 --- a/tests/generated/grid_absolute_top_overrides_bottom.rs +++ b/tests/generated/grid_absolute_top_overrides_bottom.rs @@ -3,94 +3,90 @@ fn grid_absolute_top_overrides_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(2f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(2f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node0, 2f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_absolute_with_padding.rs b/tests/generated/grid_absolute_with_padding.rs index 964340aa9..e5c8a7432 100644 --- a/tests/generated/grid_absolute_with_padding.rs +++ b/tests/generated/grid_absolute_with_padding.rs @@ -3,104 +3,98 @@ fn grid_absolute_with_padding() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: auto(), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 180f32, "x of node {:?}. Expected {}. Actual {}", node0, 180f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node1, 150f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node4, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node7, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); diff --git a/tests/generated/grid_absolute_with_padding_and_margin.rs b/tests/generated/grid_absolute_with_padding_and_margin.rs index 58b00e327..5501bd01f 100644 --- a/tests/generated/grid_absolute_with_padding_and_margin.rs +++ b/tests/generated/grid_absolute_with_padding_and_margin.rs @@ -3,116 +3,110 @@ fn grid_absolute_with_padding_and_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(3f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(3f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(3f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(3f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: auto(), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 178f32, "x of node {:?}. Expected {}. Actual {}", node0, 178f32, location.x); assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 14f32, "x of node {:?}. Expected {}. Actual {}", node1, 14f32, location.x); assert_eq!(location.y, 147f32, "y of node {:?}. Expected {}. Actual {}", node1, 147f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node4, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node7, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); diff --git a/tests/generated/grid_align_content_center.rs b/tests/generated/grid_align_content_center.rs index 9f9fa57bb..b756bd061 100644 --- a/tests/generated/grid_align_content_center.rs +++ b/tests/generated/grid_align_content_center.rs @@ -3,81 +3,79 @@ fn grid_align_content_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_content: Some(taffy::style::AlignContent::Center), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::Center), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node6, 120f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node7, 120f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_align_content_end.rs b/tests/generated/grid_align_content_end.rs index d1a1d0392..0b96c150f 100644 --- a/tests/generated/grid_align_content_end.rs +++ b/tests/generated/grid_align_content_end.rs @@ -3,81 +3,79 @@ fn grid_align_content_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_content: Some(taffy::style::AlignContent::End), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::End), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node2, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node3, 120f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node4, 120f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node5, 120f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node6, 160f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node7, 160f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_align_content_end_with_padding_border.rs b/tests/generated/grid_align_content_end_with_padding_border.rs index 4b8376fc7..0b527b182 100644 --- a/tests/generated/grid_align_content_end_with_padding_border.rs +++ b/tests/generated/grid_align_content_end_with_padding_border.rs @@ -3,93 +3,91 @@ fn grid_align_content_end_with_padding_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_content: Some(taffy::style::AlignContent::End), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::End), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); assert_eq!(location.y, 44f32, "y of node {:?}. Expected {}. Actual {}", node0, 44f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); assert_eq!(location.y, 44f32, "y of node {:?}. Expected {}. Actual {}", node1, 44f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); assert_eq!(location.y, 44f32, "y of node {:?}. Expected {}. Actual {}", node2, 44f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); assert_eq!(location.y, 84f32, "y of node {:?}. Expected {}. Actual {}", node3, 84f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); assert_eq!(location.y, 84f32, "y of node {:?}. Expected {}. Actual {}", node4, 84f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); assert_eq!(location.y, 84f32, "y of node {:?}. Expected {}. Actual {}", node5, 84f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); assert_eq!(location.y, 124f32, "y of node {:?}. Expected {}. Actual {}", node6, 124f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); assert_eq!(location.y, 124f32, "y of node {:?}. Expected {}. Actual {}", node7, 124f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); diff --git a/tests/generated/grid_align_content_space_around.rs b/tests/generated/grid_align_content_space_around.rs index d8b7de10e..487a85ee8 100644 --- a/tests/generated/grid_align_content_space_around.rs +++ b/tests/generated/grid_align_content_space_around.rs @@ -3,81 +3,79 @@ fn grid_align_content_space_around() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_content: Some(taffy::style::AlignContent::SpaceAround), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceAround), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node0, 13f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node1, 13f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 13f32, "y of node {:?}. Expected {}. Actual {}", node2, 13f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 147f32, "y of node {:?}. Expected {}. Actual {}", node6, 147f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 147f32, "y of node {:?}. Expected {}. Actual {}", node7, 147f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_align_content_space_around_with_padding_border.rs b/tests/generated/grid_align_content_space_around_with_padding_border.rs index f30c1bcbe..d3dfd949b 100644 --- a/tests/generated/grid_align_content_space_around_with_padding_border.rs +++ b/tests/generated/grid_align_content_space_around_with_padding_border.rs @@ -3,93 +3,91 @@ fn grid_align_content_space_around_with_padding_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_content: Some(taffy::style::AlignContent::SpaceAround), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceAround), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); assert_eq!(location.y, 17f32, "y of node {:?}. Expected {}. Actual {}", node0, 17f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); assert_eq!(location.y, 17f32, "y of node {:?}. Expected {}. Actual {}", node1, 17f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); assert_eq!(location.y, 17f32, "y of node {:?}. Expected {}. Actual {}", node2, 17f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node3, 68f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node4, 68f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node5, 68f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); assert_eq!(location.y, 119f32, "y of node {:?}. Expected {}. Actual {}", node6, 119f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); assert_eq!(location.y, 119f32, "y of node {:?}. Expected {}. Actual {}", node7, 119f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); diff --git a/tests/generated/grid_align_content_space_between.rs b/tests/generated/grid_align_content_space_between.rs index 8f38b2e38..7e11d28b2 100644 --- a/tests/generated/grid_align_content_space_between.rs +++ b/tests/generated/grid_align_content_space_between.rs @@ -3,81 +3,79 @@ fn grid_align_content_space_between() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_content: Some(taffy::style::AlignContent::SpaceBetween), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceBetween), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node6, 160f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node7, 160f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_align_content_space_between_with_padding_border.rs b/tests/generated/grid_align_content_space_between_with_padding_border.rs index d3fcd9e48..c9c0b0bef 100644 --- a/tests/generated/grid_align_content_space_between_with_padding_border.rs +++ b/tests/generated/grid_align_content_space_between_with_padding_border.rs @@ -3,93 +3,91 @@ fn grid_align_content_space_between_with_padding_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_content: Some(taffy::style::AlignContent::SpaceBetween), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceBetween), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node3, 68f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node4, 68f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node5, 68f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); assert_eq!(location.y, 124f32, "y of node {:?}. Expected {}. Actual {}", node6, 124f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); assert_eq!(location.y, 124f32, "y of node {:?}. Expected {}. Actual {}", node7, 124f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); diff --git a/tests/generated/grid_align_content_space_evenly.rs b/tests/generated/grid_align_content_space_evenly.rs index 5fef3974c..cb2a9bc41 100644 --- a/tests/generated/grid_align_content_space_evenly.rs +++ b/tests/generated/grid_align_content_space_evenly.rs @@ -3,81 +3,79 @@ fn grid_align_content_space_evenly() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_content: Some(taffy::style::AlignContent::SpaceEvenly), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceEvenly), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node6, 140f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node7, 140f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_align_content_space_evenly_with_padding_border.rs b/tests/generated/grid_align_content_space_evenly_with_padding_border.rs index a83c07a08..0e47d9e79 100644 --- a/tests/generated/grid_align_content_space_evenly_with_padding_border.rs +++ b/tests/generated/grid_align_content_space_evenly_with_padding_border.rs @@ -3,93 +3,91 @@ fn grid_align_content_space_evenly_with_padding_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_content: Some(taffy::style::AlignContent::SpaceEvenly), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceEvenly), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node3, 68f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node4, 68f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node5, 68f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); assert_eq!(location.y, 116f32, "y of node {:?}. Expected {}. Actual {}", node6, 116f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); assert_eq!(location.y, 116f32, "y of node {:?}. Expected {}. Actual {}", node7, 116f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); diff --git a/tests/generated/grid_align_content_start.rs b/tests/generated/grid_align_content_start.rs index d27b9ea07..83e322464 100644 --- a/tests/generated/grid_align_content_start.rs +++ b/tests/generated/grid_align_content_start.rs @@ -3,81 +3,79 @@ fn grid_align_content_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_content: Some(taffy::style::AlignContent::Start), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::Start), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_align_content_start_with_padding_border.rs b/tests/generated/grid_align_content_start_with_padding_border.rs index 0c66cdbf1..af72a427d 100644 --- a/tests/generated/grid_align_content_start_with_padding_border.rs +++ b/tests/generated/grid_align_content_start_with_padding_border.rs @@ -3,93 +3,91 @@ fn grid_align_content_start_with_padding_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_content: Some(taffy::style::AlignContent::Start), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::Start), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); diff --git a/tests/generated/grid_align_items_baseline.rs b/tests/generated/grid_align_items_baseline.rs index 0fa9610ac..a57722898 100644 --- a/tests/generated/grid_align_items_baseline.rs +++ b/tests/generated/grid_align_items_baseline.rs @@ -3,55 +3,49 @@ fn grid_align_items_baseline() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_child.rs b/tests/generated/grid_align_items_baseline_child.rs index 2128f1f5c..fcad62cfc 100644 --- a/tests/generated/grid_align_items_baseline_child.rs +++ b/tests/generated/grid_align_items_baseline_child.rs @@ -3,73 +3,65 @@ fn grid_align_items_baseline_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_child_margin.rs b/tests/generated/grid_align_items_baseline_child_margin.rs index 5cd74de40..694c61d0b 100644 --- a/tests/generated/grid_align_items_baseline_child_margin.rs +++ b/tests/generated/grid_align_items_baseline_child_margin.rs @@ -3,85 +3,77 @@ fn grid_align_items_baseline_child_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_child_margin_percent.rs b/tests/generated/grid_align_items_baseline_child_margin_percent.rs index 38b8bee3c..ed82faf03 100644 --- a/tests/generated/grid_align_items_baseline_child_margin_percent.rs +++ b/tests/generated/grid_align_items_baseline_child_margin_percent.rs @@ -3,85 +3,77 @@ fn grid_align_items_baseline_child_margin_percent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.01f32), + right: taffy::style::LengthPercentageAuto::Percent(0.01f32), + top: taffy::style::LengthPercentageAuto::Percent(0.01f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.01f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: taffy::style::LengthPercentageAuto::Percent(0.05f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.01f32), - right: taffy::style::LengthPercentageAuto::Percent(0.01f32), - top: taffy::style::LengthPercentageAuto::Percent(0.01f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.01f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node10, 1f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_child_multiline.rs b/tests/generated/grid_align_items_baseline_child_multiline.rs index e6cbcb125..3f0c23691 100644 --- a/tests/generated/grid_align_items_baseline_child_multiline.rs +++ b/tests/generated/grid_align_items_baseline_child_multiline.rs @@ -3,114 +3,100 @@ fn grid_align_items_baseline_child_multiline() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node11 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node12 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node13 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), - }, + flex_wrap: taffy::style::FlexWrap::Wrap, + grid_template_columns: vec![auto(), auto()], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10, node11, node12, node13], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(20f32), - }, + align_items: Some(taffy::style::AlignItems::Baseline), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node11 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node12 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node13 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - flex_wrap: taffy::style::FlexWrap::Wrap, - grid_template_columns: vec![auto(), auto()], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node10, node11, node12, node13], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node12).unwrap(); + let Layout { size, location, .. } = taffy.layout(node12); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node13).unwrap(); + let Layout { size, location, .. } = taffy.layout(node13); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_child_multiline_no_override_on_secondline.rs b/tests/generated/grid_align_items_baseline_child_multiline_no_override_on_secondline.rs index 8fdd5d481..cd4226634 100644 --- a/tests/generated/grid_align_items_baseline_child_multiline_no_override_on_secondline.rs +++ b/tests/generated/grid_align_items_baseline_child_multiline_no_override_on_secondline.rs @@ -3,120 +3,106 @@ fn grid_align_items_baseline_child_multiline_no_override_on_secondline() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node11 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node12 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node13 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + align_self: Some(taffy::style::AlignSelf::Baseline), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(25f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10, node11, node12, node13], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node11 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node12 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node13 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - align_self: Some(taffy::style::AlignSelf::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_columns: vec![auto(), auto()], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(25f32), - }, - ..Default::default() - }, - &[node10, node11, node12, node13], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node1, 68f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node12).unwrap(); + let Layout { size, location, .. } = taffy.layout(node12); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node13).unwrap(); + let Layout { size, location, .. } = taffy.layout(node13); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_child_multiline_override.rs b/tests/generated/grid_align_items_baseline_child_multiline_override.rs index 12b5cec31..e897a7a7c 100644 --- a/tests/generated/grid_align_items_baseline_child_multiline_override.rs +++ b/tests/generated/grid_align_items_baseline_child_multiline_override.rs @@ -3,121 +3,107 @@ fn grid_align_items_baseline_child_multiline_override() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node11 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + align_self: Some(taffy::style::AlignSelf::Baseline), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node12 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node13 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + align_self: Some(taffy::style::AlignSelf::Baseline), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(25f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(25f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10, node11, node12, node13], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node11 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - align_self: Some(taffy::style::AlignSelf::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node12 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node13 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - align_self: Some(taffy::style::AlignSelf::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(25f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_columns: vec![auto(), auto()], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(25f32), - }, - ..Default::default() - }, - &[node10, node11, node12, node13], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node1, 68f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node12).unwrap(); + let Layout { size, location, .. } = taffy.layout(node12); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node13).unwrap(); + let Layout { size, location, .. } = taffy.layout(node13); assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_child_padding.rs b/tests/generated/grid_align_items_baseline_child_padding.rs index 57ca591cd..06a226354 100644 --- a/tests/generated/grid_align_items_baseline_child_padding.rs +++ b/tests/generated/grid_align_items_baseline_child_padding.rs @@ -3,85 +3,77 @@ fn grid_align_items_baseline_child_padding() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(5f32), + right: taffy::style::LengthPercentage::Length(5f32), + top: taffy::style::LengthPercentage::Length(5f32), + bottom: taffy::style::LengthPercentage::Length(5f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(5f32), - right: taffy::style::LengthPercentage::Length(5f32), - top: taffy::style::LengthPercentage::Length(5f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(5f32), + right: taffy::style::LengthPercentage::Length(5f32), + top: taffy::style::LengthPercentage::Length(5f32), + bottom: taffy::style::LengthPercentage::Length(5f32), }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(5f32), - right: taffy::style::LengthPercentage::Length(5f32), - top: taffy::style::LengthPercentage::Length(5f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node1, 5f32, location.x); assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node10, 5f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_child_top.rs b/tests/generated/grid_align_items_baseline_child_top.rs index b96388d64..39ff26d15 100644 --- a/tests/generated/grid_align_items_baseline_child_top.rs +++ b/tests/generated/grid_align_items_baseline_child_top.rs @@ -3,79 +3,71 @@ fn grid_align_items_baseline_child_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: auto(), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: auto(), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_child_top2.rs b/tests/generated/grid_align_items_baseline_child_top2.rs index 97e3e7eab..f816ccd72 100644 --- a/tests/generated/grid_align_items_baseline_child_top2.rs +++ b/tests/generated/grid_align_items_baseline_child_top2.rs @@ -3,79 +3,71 @@ fn grid_align_items_baseline_child_top2() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: auto(), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: auto(), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_complex.rs b/tests/generated/grid_align_items_baseline_complex.rs index 6e0f1ba19..bed9cd36a 100644 --- a/tests/generated/grid_align_items_baseline_complex.rs +++ b/tests/generated/grid_align_items_baseline_complex.rs @@ -3,209 +3,181 @@ fn grid_align_items_baseline_complex() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node20 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node20], - ) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node20 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { + }, + &[node20], + ); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node60 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node6 = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { + }, + &[node60], + ); + let node70 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(5f32) }, + ..Default::default() + }); + let node7 = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node60 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node6 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node60], - ) - .unwrap(); - let node70 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(5f32) }, - ..Default::default() - }) - .unwrap(); - let node7 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node70], - ) - .unwrap(); - let node8 = taffy - .new_leaf(taffy::style::Style { + }, + &[node70], + ); + let node8 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node20).unwrap(); + let Layout { size, location, .. } = taffy.layout(node20); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node20, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node6, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node60).unwrap(); + let Layout { size, location, .. } = taffy.layout(node60); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node60, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node60, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node60, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node60, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 95f32, "y of node {:?}. Expected {}. Actual {}", node7, 95f32, location.y); - let Layout { size, location, .. } = taffy.layout(node70).unwrap(); + let Layout { size, location, .. } = taffy.layout(node70); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node70, 0f32, size.width); assert_eq!(size.height, 5f32, "height of node {:?}. Expected {}. Actual {}", node70, 5f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node70, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node70, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node8, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_double_nested_child.rs b/tests/generated/grid_align_items_baseline_double_nested_child.rs index b717fa5b0..55639d6c8 100644 --- a/tests/generated/grid_align_items_baseline_double_nested_child.rs +++ b/tests/generated/grid_align_items_baseline_double_nested_child.rs @@ -3,91 +3,81 @@ fn grid_align_items_baseline_double_nested_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(50f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node00], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(15f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(15f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node10, 15f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_multiline.rs b/tests/generated/grid_align_items_baseline_multiline.rs index 4654bef6f..3a8457762 100644 --- a/tests/generated/grid_align_items_baseline_multiline.rs +++ b/tests/generated/grid_align_items_baseline_multiline.rs @@ -3,122 +3,108 @@ fn grid_align_items_baseline_multiline() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node20 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node20 = taffy - .new_leaf(taffy::style::Style { + }, + &[node20], + ); + let node3 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), + grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node20], - ) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - grid_template_columns: vec![auto(), auto()], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node20).unwrap(); + let Layout { size, location, .. } = taffy.layout(node20); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_multiline_column.rs b/tests/generated/grid_align_items_baseline_multiline_column.rs index 37cf4b9fd..8e5bf3313 100644 --- a/tests/generated/grid_align_items_baseline_multiline_column.rs +++ b/tests/generated/grid_align_items_baseline_multiline_column.rs @@ -3,122 +3,108 @@ fn grid_align_items_baseline_multiline_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(30f32), height: taffy::style::Dimension::Length(50f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node20 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(70f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node20 = taffy - .new_leaf(taffy::style::Style { + }, + &[node20], + ); + let node3 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), + grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(70f32), - }, - ..Default::default() - }, - &[node20], - ) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - grid_template_columns: vec![auto(), auto()], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node2, 70f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node20).unwrap(); + let Layout { size, location, .. } = taffy.layout(node20); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node20, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_multiline_row_and_column.rs b/tests/generated/grid_align_items_baseline_multiline_row_and_column.rs index d3e0345dc..ebd0fa8cb 100644 --- a/tests/generated/grid_align_items_baseline_multiline_row_and_column.rs +++ b/tests/generated/grid_align_items_baseline_multiline_row_and_column.rs @@ -3,122 +3,108 @@ fn grid_align_items_baseline_multiline_row_and_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: taffy::style::Dimension::Length(50f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { + }, + &[node10], + ); + let node20 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node20 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(20f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }, - &[node20], - ) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { + }, + &[node20], + ); + let node3 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), + grid_template_columns: vec![auto(), auto()], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - grid_template_columns: vec![auto(), auto()], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node2, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node20).unwrap(); + let Layout { size, location, .. } = taffy.layout(node20); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node20, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); diff --git a/tests/generated/grid_align_items_baseline_nested_column.rs b/tests/generated/grid_align_items_baseline_nested_column.rs index 67a7faa78..a8ee62894 100644 --- a/tests/generated/grid_align_items_baseline_nested_column.rs +++ b/tests/generated/grid_align_items_baseline_nested_column.rs @@ -3,99 +3,87 @@ fn grid_align_items_baseline_nested_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node100 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node101 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node10 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(80f32), }, ..Default::default() - }) - .unwrap(); - let node100 = taffy - .new_leaf(taffy::style::Style { + }, + &[node100, node101], + ); + let node1 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node101 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(40f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(80f32), - }, - ..Default::default() - }, - &[node100, node101], - ) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Baseline), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node10, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node100).unwrap(); + let Layout { size, location, .. } = taffy.layout(node100); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node100, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node101).unwrap(); + let Layout { size, location, .. } = taffy.layout(node101); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node101, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node101, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node101, 0f32, location.x); diff --git a/tests/generated/grid_align_items_sized_center.rs b/tests/generated/grid_align_items_sized_center.rs index 4ebd3ca20..7e67a9c21 100644 --- a/tests/generated/grid_align_items_sized_center.rs +++ b/tests/generated/grid_align_items_sized_center.rs @@ -3,59 +3,53 @@ fn grid_align_items_sized_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Center), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Center), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); diff --git a/tests/generated/grid_align_items_sized_end.rs b/tests/generated/grid_align_items_sized_end.rs index e0aa4614e..f74fb0020 100644 --- a/tests/generated/grid_align_items_sized_end.rs +++ b/tests/generated/grid_align_items_sized_end.rs @@ -3,59 +3,53 @@ fn grid_align_items_sized_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::End), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::End), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); diff --git a/tests/generated/grid_align_items_sized_start.rs b/tests/generated/grid_align_items_sized_start.rs index 640503ce7..36077edde 100644 --- a/tests/generated/grid_align_items_sized_start.rs +++ b/tests/generated/grid_align_items_sized_start.rs @@ -3,59 +3,53 @@ fn grid_align_items_sized_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Start), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Start), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); diff --git a/tests/generated/grid_align_items_sized_stretch.rs b/tests/generated/grid_align_items_sized_stretch.rs index 3768e050f..ed58125a5 100644 --- a/tests/generated/grid_align_items_sized_stretch.rs +++ b/tests/generated/grid_align_items_sized_stretch.rs @@ -3,59 +3,53 @@ fn grid_align_items_sized_stretch() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Stretch), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - align_items: Some(taffy::style::AlignItems::Stretch), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); diff --git a/tests/generated/grid_align_self_sized_all.rs b/tests/generated/grid_align_self_sized_all.rs index ed8bce4f4..ed8c23a90 100644 --- a/tests/generated/grid_align_self_sized_all.rs +++ b/tests/generated/grid_align_self_sized_all.rs @@ -3,146 +3,128 @@ fn grid_align_self_sized_all() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Start), + let node0 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node6 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node7 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::End), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::End), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node6 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node7 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node3, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node3, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node5, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs b/tests/generated/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs index 8299badc0..1d5f30386 100644 --- a/tests/generated/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs +++ b/tests/generated/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs @@ -3,42 +3,38 @@ fn grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: taffy::style::LengthPercentageAuto::Percent(0.05f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node0, 360f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_absolute_fill_height_from_inset.rs b/tests/generated/grid_aspect_ratio_absolute_fill_height_from_inset.rs index ee3f8d060..2c8ba060b 100644 --- a/tests/generated/grid_aspect_ratio_absolute_fill_height_from_inset.rs +++ b/tests/generated/grid_aspect_ratio_absolute_fill_height_from_inset.rs @@ -3,42 +3,38 @@ fn grid_aspect_ratio_absolute_fill_height_from_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.1f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0, 107f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_absolute_fill_width_from_inset.rs b/tests/generated/grid_aspect_ratio_absolute_fill_width_from_inset.rs index 88bc1423d..09285c493 100644 --- a/tests/generated/grid_aspect_ratio_absolute_fill_width_from_inset.rs +++ b/tests/generated/grid_aspect_ratio_absolute_fill_width_from_inset.rs @@ -3,42 +3,38 @@ fn grid_aspect_ratio_absolute_fill_width_from_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.3f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.3f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_absolute_height_overrides_inset.rs b/tests/generated/grid_aspect_ratio_absolute_height_overrides_inset.rs index 377f29fb3..ebf2e086c 100644 --- a/tests/generated/grid_aspect_ratio_absolute_height_overrides_inset.rs +++ b/tests/generated/grid_aspect_ratio_absolute_height_overrides_inset.rs @@ -3,43 +3,39 @@ fn grid_aspect_ratio_absolute_height_overrides_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.1f32) }, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.3f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.1f32) }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.3f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node0, 90f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_absolute_width_overrides_inset.rs b/tests/generated/grid_aspect_ratio_absolute_width_overrides_inset.rs index 244566afb..7be7dcf68 100644 --- a/tests/generated/grid_aspect_ratio_absolute_width_overrides_inset.rs +++ b/tests/generated/grid_aspect_ratio_absolute_width_overrides_inset.rs @@ -3,43 +3,39 @@ fn grid_aspect_ratio_absolute_width_overrides_inset() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.4f32), height: auto() }, - aspect_ratio: Some(3f32), - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.1f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.4f32), height: auto() }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(300f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); assert_eq!(size.height, 53f32, "height of node {:?}. Expected {}. Actual {}", node0, 53f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_child_fill_content_height.rs b/tests/generated/grid_aspect_ratio_child_fill_content_height.rs index 2d7a5ac4d..9035dfeaf 100644 --- a/tests/generated/grid_aspect_ratio_child_fill_content_height.rs +++ b/tests/generated/grid_aspect_ratio_child_fill_content_height.rs @@ -3,48 +3,42 @@ fn grid_aspect_ratio_child_fill_content_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { aspect_ratio: Some(0.5f32), ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - Some(0.5f32), - ) - }), - ) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { aspect_ratio: Some(0.5f32), ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(0.5f32), + ) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_child_fill_content_width.rs b/tests/generated/grid_aspect_ratio_child_fill_content_width.rs index b73ac79e8..bc1c563f0 100644 --- a/tests/generated/grid_aspect_ratio_child_fill_content_width.rs +++ b/tests/generated/grid_aspect_ratio_child_fill_content_width.rs @@ -3,48 +3,42 @@ fn grid_aspect_ratio_child_fill_content_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { aspect_ratio: Some(2f32), ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - Some(2f32), - ) - }), - ) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { aspect_ratio: Some(2f32), ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_fill_child_height.rs b/tests/generated/grid_aspect_ratio_fill_child_height.rs index 9b8c08aed..47c1e0e03 100644 --- a/tests/generated/grid_aspect_ratio_fill_child_height.rs +++ b/tests/generated/grid_aspect_ratio_fill_child_height.rs @@ -3,36 +3,32 @@ fn grid_aspect_ratio_fill_child_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node0, 25f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_fill_child_max_height.rs b/tests/generated/grid_aspect_ratio_fill_child_max_height.rs index 26d2786a1..6361e1f55 100644 --- a/tests/generated/grid_aspect_ratio_fill_child_max_height.rs +++ b/tests/generated/grid_aspect_ratio_fill_child_max_height.rs @@ -3,48 +3,44 @@ fn grid_aspect_ratio_fill_child_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, - aspect_ratio: Some(2f32), - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Vertical, + Some(2f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Vertical, - Some(2f32), - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_fill_child_max_width.rs b/tests/generated/grid_aspect_ratio_fill_child_max_width.rs index 60e965ed4..270fb7c36 100644 --- a/tests/generated/grid_aspect_ratio_fill_child_max_width.rs +++ b/tests/generated/grid_aspect_ratio_fill_child_max_width.rs @@ -3,48 +3,44 @@ fn grid_aspect_ratio_fill_child_max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - aspect_ratio: Some(2f32), - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - Some(2f32), - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_fill_child_min_height.rs b/tests/generated/grid_aspect_ratio_fill_child_min_height.rs index edc8b7c28..1b80ae3ac 100644 --- a/tests/generated/grid_aspect_ratio_fill_child_min_height.rs +++ b/tests/generated/grid_aspect_ratio_fill_child_min_height.rs @@ -3,36 +3,32 @@ fn grid_aspect_ratio_fill_child_min_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_fill_child_min_width.rs b/tests/generated/grid_aspect_ratio_fill_child_min_width.rs index 842d2d0b8..61af3aaba 100644 --- a/tests/generated/grid_aspect_ratio_fill_child_min_width.rs +++ b/tests/generated/grid_aspect_ratio_fill_child_min_width.rs @@ -3,48 +3,44 @@ fn grid_aspect_ratio_fill_child_min_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - aspect_ratio: Some(2f32), - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "\n \n "; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "\n \n "; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - Some(2f32), - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_fill_child_width.rs b/tests/generated/grid_aspect_ratio_fill_child_width.rs index 7c7cfa794..ea3c74d49 100644 --- a/tests/generated/grid_aspect_ratio_fill_child_width.rs +++ b/tests/generated/grid_aspect_ratio_fill_child_width.rs @@ -3,36 +3,32 @@ fn grid_aspect_ratio_fill_child_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - aspect_ratio: Some(2f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes.rs b/tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes.rs index 6c89ec77e..c910d3b71 100644 --- a/tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes.rs +++ b/tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes.rs @@ -3,39 +3,35 @@ fn grid_aspect_ratio_overriden_by_explicit_sizes() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - aspect_ratio: Some(2f32), ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes_flex.rs b/tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes_flex.rs index a6053e45b..04048a13a 100644 --- a/tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes_flex.rs +++ b/tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes_flex.rs @@ -3,39 +3,35 @@ fn grid_aspect_ratio_overriden_by_explicit_sizes_flex() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + aspect_ratio: Some(2f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - aspect_ratio: Some(2f32), ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_auto_columns.rs b/tests/generated/grid_auto_columns.rs index 8c20713a6..1f8e796d3 100644 --- a/tests/generated/grid_auto_columns.rs +++ b/tests/generated/grid_auto_columns.rs @@ -3,77 +3,73 @@ fn grid_auto_columns() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_column: taffy::geometry::Line { start: line(-3i16), end: taffy::style::GridPlacement::Auto }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_column: taffy::geometry::Line { start: line(-3i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(100f32)], + grid_template_columns: vec![length(40f32)], + grid_auto_columns: vec![length(10f32), length(20f32), length(30f32)], + grid_auto_flow: taffy::style::GridAutoFlow::Column, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(100f32)], - grid_template_columns: vec![length(40f32)], - grid_auto_columns: vec![length(10f32), length(20f32), length(30f32)], - grid_auto_flow: taffy::style::GridAutoFlow::Column, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 190f32, "width of node {:?}. Expected {}. Actual {}", node, 190f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node4, 100f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node5, 100f32, size.height); assert_eq!(location.x, 130f32, "x of node {:?}. Expected {}. Actual {}", node5, 130f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node6, 100f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node6, 140f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node6, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node7, 100f32, size.height); assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node7, 160f32, location.x); diff --git a/tests/generated/grid_auto_columns_fixed_width.rs b/tests/generated/grid_auto_columns_fixed_width.rs index da09c737c..f1ff0ab37 100644 --- a/tests/generated/grid_auto_columns_fixed_width.rs +++ b/tests/generated/grid_auto_columns_fixed_width.rs @@ -3,125 +3,123 @@ fn grid_auto_columns_fixed_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node10 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node11 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node12 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node13 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node14 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node15 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), auto(), length(40f32), auto()], - grid_template_columns: vec![length(40f32), auto(), length(40f32), auto()], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node10 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node11 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node12 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node13 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node14 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node15 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), auto(), length(40f32), auto()], + grid_template_columns: vec![length(40f32), auto(), length(40f32), auto()], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[ - node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13, - node14, node15, - ], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[ + node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13, + node14, node15, + ], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node3, 140f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node4, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node6, 60f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node6, 100f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node7, 140f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node8, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node9).unwrap(); + let Layout { size, location, .. } = taffy.layout(node9); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node9, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node9, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node9, 40f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node9, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node10, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node10, 40f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node10, 100f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node10, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node11, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node11, 40f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node11, 140f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node11, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node12).unwrap(); + let Layout { size, location, .. } = taffy.layout(node12); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node12, 40f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node12, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node12, 140f32, location.y); - let Layout { size, location, .. } = taffy.layout(node13).unwrap(); + let Layout { size, location, .. } = taffy.layout(node13); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node13, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node13, 60f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node13, 40f32, location.x); assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node13, 140f32, location.y); - let Layout { size, location, .. } = taffy.layout(node14).unwrap(); + let Layout { size, location, .. } = taffy.layout(node14); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node14, 40f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node14, 60f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node14, 100f32, location.x); assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node14, 140f32, location.y); - let Layout { size, location, .. } = taffy.layout(node15).unwrap(); + let Layout { size, location, .. } = taffy.layout(node15); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node15, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node15, 60f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node15, 140f32, location.x); diff --git a/tests/generated/grid_auto_fill_fixed_size.rs b/tests/generated/grid_auto_fill_fixed_size.rs index 4fceedef7..43079aeb3 100644 --- a/tests/generated/grid_auto_fill_fixed_size.rs +++ b/tests/generated/grid_auto_fill_fixed_size.rs @@ -3,80 +3,78 @@ fn grid_auto_fill_fixed_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), repeat(GridTrackRepetition::AutoFill, vec![length(40f32)])], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), repeat(GridTrackRepetition::AutoFill, vec![length(40f32)])], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_auto_fill_with_empty_auto_track.rs b/tests/generated/grid_auto_fill_with_empty_auto_track.rs index 5de22241b..38c62fcb8 100644 --- a/tests/generated/grid_auto_fill_with_empty_auto_track.rs +++ b/tests/generated/grid_auto_fill_with_empty_auto_track.rs @@ -3,39 +3,37 @@ fn grid_auto_fill_with_empty_auto_track() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![repeat(GridTrackRepetition::AutoFill, vec![length(40f32)])], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![repeat(GridTrackRepetition::AutoFill, vec![length(40f32)])], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); diff --git a/tests/generated/grid_auto_fit_with_empty_auto_track.rs b/tests/generated/grid_auto_fit_with_empty_auto_track.rs index e838e9d27..8b7924bf0 100644 --- a/tests/generated/grid_auto_fit_with_empty_auto_track.rs +++ b/tests/generated/grid_auto_fit_with_empty_auto_track.rs @@ -3,39 +3,37 @@ fn grid_auto_fit_with_empty_auto_track() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![repeat(GridTrackRepetition::AutoFit, vec![length(40f32)])], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![repeat(GridTrackRepetition::AutoFit, vec![length(40f32)])], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node0, 13f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node1, 67f32, location.x); diff --git a/tests/generated/grid_auto_rows.rs b/tests/generated/grid_auto_rows.rs index 692120078..2a98b2a11 100644 --- a/tests/generated/grid_auto_rows.rs +++ b/tests/generated/grid_auto_rows.rs @@ -3,76 +3,72 @@ fn grid_auto_rows() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(-4i16), end: taffy::style::GridPlacement::Auto }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(-4i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![length(100f32)], + grid_auto_rows: vec![length(10f32), length(20f32), length(30f32)], ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![length(100f32)], - grid_auto_rows: vec![length(10f32), length(20f32), length(30f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node, 180f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node3, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node3, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node4, 100f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node4, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node5, 100f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node5, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node5, 120f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node6, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node6, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node6, 150f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node7, 100f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x); diff --git a/tests/generated/grid_auto_single_item.rs b/tests/generated/grid_auto_single_item.rs index e8ae54a8f..0dff41c9d 100644 --- a/tests/generated/grid_auto_single_item.rs +++ b/tests/generated/grid_auto_single_item.rs @@ -3,81 +3,77 @@ fn grid_auto_single_item() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), auto(), length(40f32)], ..Default::default() - }) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), auto(), length(40f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node2, 140f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node4, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node5, 140f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node7, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node8, 140f32, location.x); diff --git a/tests/generated/grid_auto_single_item_fixed_width.rs b/tests/generated/grid_auto_single_item_fixed_width.rs index 17b964f22..efb271cdc 100644 --- a/tests/generated/grid_auto_single_item_fixed_width.rs +++ b/tests/generated/grid_auto_single_item_fixed_width.rs @@ -3,82 +3,78 @@ fn grid_auto_single_item_fixed_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), auto(), auto()], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), auto(), auto()], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node1, 130f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node2, 170f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node4, 130f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node5, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node5, 170f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node7, 130f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node8, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node8, 170f32, location.x); diff --git a/tests/generated/grid_auto_single_item_fixed_width_with_definite_width.rs b/tests/generated/grid_auto_single_item_fixed_width_with_definite_width.rs index b780cadc8..09cfbe8ce 100644 --- a/tests/generated/grid_auto_single_item_fixed_width_with_definite_width.rs +++ b/tests/generated/grid_auto_single_item_fixed_width_with_definite_width.rs @@ -3,82 +3,78 @@ fn grid_auto_single_item_fixed_width_with_definite_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), auto(), auto()], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), auto(), auto()], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node2, 170f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node4, 130f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node5, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node5, 170f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node7, 130f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node8, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 170f32, "x of node {:?}. Expected {}. Actual {}", node8, 170f32, location.x); diff --git a/tests/generated/grid_auto_takes_precedence_over_fr.rs b/tests/generated/grid_auto_takes_precedence_over_fr.rs index a2ed9dd92..f6e3b1f53 100644 --- a/tests/generated/grid_auto_takes_precedence_over_fr.rs +++ b/tests/generated/grid_auto_takes_precedence_over_fr.rs @@ -3,38 +3,36 @@ fn grid_auto_takes_precedence_over_fr() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![auto(), fr(1f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![auto(), fr(1f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/grid_basic.rs b/tests/generated/grid_basic.rs index 116cb81f5..1d01ba2b3 100644 --- a/tests/generated/grid_basic.rs +++ b/tests/generated/grid_basic.rs @@ -3,80 +3,78 @@ fn grid_basic() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_basic_implicit_tracks.rs b/tests/generated/grid_basic_implicit_tracks.rs index 4b4477cc8..609d60081 100644 --- a/tests/generated/grid_basic_implicit_tracks.rs +++ b/tests/generated/grid_basic_implicit_tracks.rs @@ -3,42 +3,38 @@ fn grid_basic_implicit_tracks() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(35f32), - height: taffy::style::Dimension::Length(35f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(35f32), + height: taffy::style::Dimension::Length(35f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![length(40f32)], ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![length(40f32)], - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 75f32, "height of node {:?}. Expected {}. Actual {}", node, 75f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node1, 35f32, size.width); assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node1, 35f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/grid_basic_with_overflow.rs b/tests/generated/grid_basic_with_overflow.rs index e358a0c86..0019d6af3 100644 --- a/tests/generated/grid_basic_with_overflow.rs +++ b/tests/generated/grid_basic_with_overflow.rs @@ -3,86 +3,84 @@ fn grid_basic_with_overflow() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8, node9], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8, node9], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node9).unwrap(); + let Layout { size, location, .. } = taffy.layout(node9); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node9, 40f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node9, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node9, 0f32, location.x); diff --git a/tests/generated/grid_basic_with_padding.rs b/tests/generated/grid_basic_with_padding.rs index a36d6df59..958e68736 100644 --- a/tests/generated/grid_basic_with_padding.rs +++ b/tests/generated/grid_basic_with_padding.rs @@ -3,82 +3,80 @@ fn grid_basic_with_padding() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node6, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node8, 120f32, location.x); diff --git a/tests/generated/grid_display_none_fixed_size.rs b/tests/generated/grid_display_none_fixed_size.rs index 4e6b86f8c..0afb5e8a2 100644 --- a/tests/generated/grid_display_none_fixed_size.rs +++ b/tests/generated/grid_display_none_fixed_size.rs @@ -3,45 +3,41 @@ fn grid_display_none_fixed_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - display: taffy::style::Display::None, + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/grid_fit_content_percent_definite_argument.rs b/tests/generated/grid_fit_content_percent_definite_argument.rs index da3c53e97..26b998d9c 100644 --- a/tests/generated/grid_fit_content_percent_definite_argument.rs +++ b/tests/generated/grid_fit_content_percent_definite_argument.rs @@ -3,43 +3,33 @@ fn grid_fit_content_percent_definite_argument() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![fit_content(percent(0.5f32))], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![fit_content(percent(0.5f32))], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_fit_content_percent_definite_max_content.rs b/tests/generated/grid_fit_content_percent_definite_max_content.rs index f0e07f6aa..3527b25b2 100644 --- a/tests/generated/grid_fit_content_percent_definite_max_content.rs +++ b/tests/generated/grid_fit_content_percent_definite_max_content.rs @@ -3,43 +3,33 @@ fn grid_fit_content_percent_definite_max_content() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![fit_content(percent(0.5f32))], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![fit_content(percent(0.5f32))], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_fit_content_percent_definite_min_content.rs b/tests/generated/grid_fit_content_percent_definite_min_content.rs index 109cf67f7..3c4146c30 100644 --- a/tests/generated/grid_fit_content_percent_definite_min_content.rs +++ b/tests/generated/grid_fit_content_percent_definite_min_content.rs @@ -3,43 +3,33 @@ fn grid_fit_content_percent_definite_min_content() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![fit_content(percent(0.5f32))], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![fit_content(percent(0.5f32))], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_fit_content_percent_indefinite_argument.rs b/tests/generated/grid_fit_content_percent_indefinite_argument.rs index bd6be2e20..28911143d 100644 --- a/tests/generated/grid_fit_content_percent_indefinite_argument.rs +++ b/tests/generated/grid_fit_content_percent_indefinite_argument.rs @@ -3,42 +3,32 @@ fn grid_fit_content_percent_indefinite_argument() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![fit_content(percent(0.5f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![fit_content(percent(0.5f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_fit_content_percent_indefinite_max_content.rs b/tests/generated/grid_fit_content_percent_indefinite_max_content.rs index ef3abe66e..242381520 100644 --- a/tests/generated/grid_fit_content_percent_indefinite_max_content.rs +++ b/tests/generated/grid_fit_content_percent_indefinite_max_content.rs @@ -3,42 +3,32 @@ fn grid_fit_content_percent_indefinite_max_content() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![fit_content(percent(0.5f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![fit_content(percent(0.5f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_fit_content_percent_indefinite_max_content_hidden.rs b/tests/generated/grid_fit_content_percent_indefinite_max_content_hidden.rs index bd4749bbd..f8efba814 100644 --- a/tests/generated/grid_fit_content_percent_indefinite_max_content_hidden.rs +++ b/tests/generated/grid_fit_content_percent_indefinite_max_content_hidden.rs @@ -3,49 +3,36 @@ fn grid_fit_content_percent_indefinite_max_content_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![fit_content(percent(0.5f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![fit_content(percent(0.5f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_fit_content_percent_indefinite_min_content.rs b/tests/generated/grid_fit_content_percent_indefinite_min_content.rs index db6c79564..9569ff656 100644 --- a/tests/generated/grid_fit_content_percent_indefinite_min_content.rs +++ b/tests/generated/grid_fit_content_percent_indefinite_min_content.rs @@ -3,42 +3,32 @@ fn grid_fit_content_percent_indefinite_min_content() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![fit_content(percent(0.5f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![fit_content(percent(0.5f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_fit_content_percent_indefinite_min_content_hidden.rs b/tests/generated/grid_fit_content_percent_indefinite_min_content_hidden.rs index b94308a53..793fb6bc1 100644 --- a/tests/generated/grid_fit_content_percent_indefinite_min_content_hidden.rs +++ b/tests/generated/grid_fit_content_percent_indefinite_min_content_hidden.rs @@ -3,49 +3,36 @@ fn grid_fit_content_percent_indefinite_min_content_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![fit_content(percent(0.5f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![fit_content(percent(0.5f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_fit_content_points_argument.rs b/tests/generated/grid_fit_content_points_argument.rs index 06762d6c7..6ee2d224c 100644 --- a/tests/generated/grid_fit_content_points_argument.rs +++ b/tests/generated/grid_fit_content_points_argument.rs @@ -3,42 +3,32 @@ fn grid_fit_content_points_argument() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![fit_content(length(30f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![fit_content(length(30f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_fit_content_points_max_content.rs b/tests/generated/grid_fit_content_points_max_content.rs index a6d638ad4..30586dad3 100644 --- a/tests/generated/grid_fit_content_points_max_content.rs +++ b/tests/generated/grid_fit_content_points_max_content.rs @@ -3,42 +3,32 @@ fn grid_fit_content_points_max_content() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![fit_content(length(30f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![fit_content(length(30f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_fit_content_points_min_content.rs b/tests/generated/grid_fit_content_points_min_content.rs index a76717c23..3c23eead1 100644 --- a/tests/generated/grid_fit_content_points_min_content.rs +++ b/tests/generated/grid_fit_content_points_min_content.rs @@ -3,42 +3,32 @@ fn grid_fit_content_points_min_content() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![fit_content(length(30f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![fit_content(length(30f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_fit_content_points_min_content_hidden.rs b/tests/generated/grid_fit_content_points_min_content_hidden.rs index ff23d6d00..42bde2a01 100644 --- a/tests/generated/grid_fit_content_points_min_content_hidden.rs +++ b/tests/generated/grid_fit_content_points_min_content_hidden.rs @@ -3,49 +3,36 @@ fn grid_fit_content_points_min_content_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![fit_content(length(30f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![fit_content(length(30f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_fr_fixed_size_no_content_proportions.rs b/tests/generated/grid_fr_fixed_size_no_content_proportions.rs index e34d114e8..286762804 100644 --- a/tests/generated/grid_fr_fixed_size_no_content_proportions.rs +++ b/tests/generated/grid_fr_fixed_size_no_content_proportions.rs @@ -3,41 +3,39 @@ fn grid_fr_fixed_size_no_content_proportions() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![fr(1f32), fr(2f32), fr(3f32)], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![fr(1f32), fr(2f32), fr(3f32)], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node0, 33f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 67f32, "width of node {:?}. Expected {}. Actual {}", node1, 67f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 33f32, "x of node {:?}. Expected {}. Actual {}", node1, 33f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); diff --git a/tests/generated/grid_fr_fixed_size_no_content_proportions_sub_1_sum.rs b/tests/generated/grid_fr_fixed_size_no_content_proportions_sub_1_sum.rs index ca839fd4a..57012c084 100644 --- a/tests/generated/grid_fr_fixed_size_no_content_proportions_sub_1_sum.rs +++ b/tests/generated/grid_fr_fixed_size_no_content_proportions_sub_1_sum.rs @@ -3,35 +3,33 @@ fn grid_fr_fixed_size_no_content_proportions_sub_1_sum() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![fr(0.3f32), fr(0.2f32)], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![fr(0.3f32), fr(0.2f32)], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); diff --git a/tests/generated/grid_fr_fixed_size_single_item.rs b/tests/generated/grid_fr_fixed_size_single_item.rs index a34d1eb13..6ec3efb7f 100644 --- a/tests/generated/grid_fr_fixed_size_single_item.rs +++ b/tests/generated/grid_fr_fixed_size_single_item.rs @@ -3,85 +3,81 @@ fn grid_fr_fixed_size_single_item() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), fr(1f32), fr(1f32)], - grid_template_columns: vec![length(40f32), fr(1f32), fr(1f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), fr(1f32), fr(1f32)], + grid_template_columns: vec![length(40f32), fr(1f32), fr(1f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node2, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node2, 140f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node3, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node4, 100f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node4, 80f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node5, 80f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node5, 140f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node6, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node6, 120f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node7, 100f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node7, 80f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node7, 120f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node8, 60f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node8, 80f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node8, 140f32, location.x); diff --git a/tests/generated/grid_fr_no_sized_items_indefinite.rs b/tests/generated/grid_fr_no_sized_items_indefinite.rs index 58b2ef73d..ed7acbcc3 100644 --- a/tests/generated/grid_fr_no_sized_items_indefinite.rs +++ b/tests/generated/grid_fr_no_sized_items_indefinite.rs @@ -3,76 +3,74 @@ fn grid_fr_no_sized_items_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), fr(1f32), fr(1f32)], - grid_template_columns: vec![length(40f32), fr(1f32), fr(1f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), fr(1f32), fr(1f32)], + grid_template_columns: vec![length(40f32), fr(1f32), fr(1f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node5, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node6, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node7, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node7, 0f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node8, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node8, 40f32, location.x); diff --git a/tests/generated/grid_fr_single_item_indefinite.rs b/tests/generated/grid_fr_single_item_indefinite.rs index 8de1c863d..799dce7fd 100644 --- a/tests/generated/grid_fr_single_item_indefinite.rs +++ b/tests/generated/grid_fr_single_item_indefinite.rs @@ -3,85 +3,78 @@ fn grid_fr_single_item_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), fr(1f32), fr(1f32)], + grid_template_columns: vec![length(40f32), fr(1f32), fr(1f32)], + size: taffy::geometry::Size { width: taffy::style::Dimension::Auto, height: taffy::style::Dimension::Auto }, ..Default::default() - }) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), fr(1f32), fr(1f32)], - grid_template_columns: vec![length(40f32), fr(1f32), fr(1f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Auto, - height: taffy::style::Dimension::Auto, - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node2, 140f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node4, 100f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node5, 100f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node5, 140f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node6, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node7, 100f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node7, 0f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node8, 100f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node8, 140f32, location.x); diff --git a/tests/generated/grid_fr_span_2_proportion.rs b/tests/generated/grid_fr_span_2_proportion.rs index 5886c7924..cd4f17695 100644 --- a/tests/generated/grid_fr_span_2_proportion.rs +++ b/tests/generated/grid_fr_span_2_proportion.rs @@ -3,49 +3,45 @@ fn grid_fr_span_2_proportion() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_column: taffy::geometry::Line { - start: taffy::style::GridPlacement::Span(2u16), - end: taffy::style::GridPlacement::Auto, - }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32)], + grid_template_columns: vec![fr(1f32), fr(2f32)], ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32)], - grid_template_columns: vec![fr(1f32), fr(2f32)], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); diff --git a/tests/generated/grid_fr_span_2_proportion_sub_1_sum.rs b/tests/generated/grid_fr_span_2_proportion_sub_1_sum.rs index 7768a86af..3146936e1 100644 --- a/tests/generated/grid_fr_span_2_proportion_sub_1_sum.rs +++ b/tests/generated/grid_fr_span_2_proportion_sub_1_sum.rs @@ -3,49 +3,45 @@ fn grid_fr_span_2_proportion_sub_1_sum() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_column: taffy::geometry::Line { - start: taffy::style::GridPlacement::Span(2u16), - end: taffy::style::GridPlacement::Auto, - }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32)], + grid_template_columns: vec![fr(0.2f32), fr(0.3f32)], ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32)], - grid_template_columns: vec![fr(0.2f32), fr(0.3f32)], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 24f32, "width of node {:?}. Expected {}. Actual {}", node1, 24f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node2, 36f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 24f32, "x of node {:?}. Expected {}. Actual {}", node2, 24f32, location.x); diff --git a/tests/generated/grid_fr_span_2_proportion_with_non_spanned_track.rs b/tests/generated/grid_fr_span_2_proportion_with_non_spanned_track.rs index 90df6a552..fc6c96822 100644 --- a/tests/generated/grid_fr_span_2_proportion_with_non_spanned_track.rs +++ b/tests/generated/grid_fr_span_2_proportion_with_non_spanned_track.rs @@ -3,61 +3,57 @@ fn grid_fr_span_2_proportion_with_non_spanned_track() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_column: taffy::geometry::Line { - start: taffy::style::GridPlacement::Span(2u16), - end: taffy::style::GridPlacement::Auto, - }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32)], + grid_template_columns: vec![fr(1f32), fr(2f32), fr(3f32)], ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32)], - grid_template_columns: vec![fr(1f32), fr(2f32), fr(3f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node3, 20f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node4, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node4, 60f32, location.x); diff --git a/tests/generated/grid_fr_span_2_proportion_zero_sum.rs b/tests/generated/grid_fr_span_2_proportion_zero_sum.rs index 2d83227d4..5f44803a7 100644 --- a/tests/generated/grid_fr_span_2_proportion_zero_sum.rs +++ b/tests/generated/grid_fr_span_2_proportion_zero_sum.rs @@ -3,49 +3,45 @@ fn grid_fr_span_2_proportion_zero_sum() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_column: taffy::geometry::Line { - start: taffy::style::GridPlacement::Span(2u16), - end: taffy::style::GridPlacement::Auto, - }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32)], + grid_template_columns: vec![fr(0f32), fr(0f32)], ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32)], - grid_template_columns: vec![fr(0f32), fr(0f32)], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node2, 30f32, location.x); diff --git a/tests/generated/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.rs b/tests/generated/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.rs index 5465724e4..f98d257f1 100644 --- a/tests/generated/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.rs +++ b/tests/generated/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.rs @@ -3,61 +3,57 @@ fn grid_fr_span_2_proportion_zero_sum_with_non_spanned_track() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_column: taffy::geometry::Line { - start: taffy::style::GridPlacement::Span(2u16), - end: taffy::style::GridPlacement::Auto, - }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32)], + grid_template_columns: vec![fr(0f32), fr(0f32), fr(0f32)], ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32)], - grid_template_columns: vec![fr(0f32), fr(0f32), fr(0f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node4, 60f32, location.x); diff --git a/tests/generated/grid_gap.rs b/tests/generated/grid_gap.rs index 1d6fbf663..73126863a 100644 --- a/tests/generated/grid_gap.rs +++ b/tests/generated/grid_gap.rs @@ -3,84 +3,82 @@ fn grid_gap() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - gap: taffy::geometry::Size { - width: taffy::style::LengthPercentage::Length(40f32), - height: taffy::style::LengthPercentage::Length(40f32), - }, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Length(40f32), + height: taffy::style::LengthPercentage::Length(40f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node2, 160f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node5, 160f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node6, 160f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node7, 160f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node8, 160f32, location.x); diff --git a/tests/generated/grid_hidden.rs b/tests/generated/grid_hidden.rs index b2ac34dca..9c6682ceb 100644 --- a/tests/generated/grid_hidden.rs +++ b/tests/generated/grid_hidden.rs @@ -3,83 +3,78 @@ fn grid_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = - taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node6, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node6, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node6, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_justify_content_center.rs b/tests/generated/grid_justify_content_center.rs index db5de6c9c..778bc3042 100644 --- a/tests/generated/grid_justify_content_center.rs +++ b/tests/generated/grid_justify_content_center.rs @@ -3,81 +3,79 @@ fn grid_justify_content_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_content: Some(taffy::style::JustifyContent::Center), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::Center), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node8, 120f32, location.x); diff --git a/tests/generated/grid_justify_content_center_with_padding_border.rs b/tests/generated/grid_justify_content_center_with_padding_border.rs index 436eafe92..b49129588 100644 --- a/tests/generated/grid_justify_content_center_with_padding_border.rs +++ b/tests/generated/grid_justify_content_center_with_padding_border.rs @@ -3,93 +3,91 @@ fn grid_justify_content_center_with_padding_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_content: Some(taffy::style::JustifyContent::Center), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::Center), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 52f32, "x of node {:?}. Expected {}. Actual {}", node0, 52f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node1, 92f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 132f32, "x of node {:?}. Expected {}. Actual {}", node2, 132f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 52f32, "x of node {:?}. Expected {}. Actual {}", node3, 52f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node4, 92f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 132f32, "x of node {:?}. Expected {}. Actual {}", node5, 132f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 52f32, "x of node {:?}. Expected {}. Actual {}", node6, 52f32, location.x); assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node7, 92f32, location.x); assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 132f32, "x of node {:?}. Expected {}. Actual {}", node8, 132f32, location.x); diff --git a/tests/generated/grid_justify_content_end.rs b/tests/generated/grid_justify_content_end.rs index a3ef4d553..e9cbcac06 100644 --- a/tests/generated/grid_justify_content_end.rs +++ b/tests/generated/grid_justify_content_end.rs @@ -3,81 +3,79 @@ fn grid_justify_content_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_content: Some(taffy::style::JustifyContent::End), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::End), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node1, 120f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node2, 160f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node5, 160f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node7, 120f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node8, 160f32, location.x); diff --git a/tests/generated/grid_justify_content_end_with_padding_border.rs b/tests/generated/grid_justify_content_end_with_padding_border.rs index d5f48637d..c64b1f652 100644 --- a/tests/generated/grid_justify_content_end_with_padding_border.rs +++ b/tests/generated/grid_justify_content_end_with_padding_border.rs @@ -3,93 +3,91 @@ fn grid_justify_content_end_with_padding_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_content: Some(taffy::style::JustifyContent::End), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::End), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 56f32, "x of node {:?}. Expected {}. Actual {}", node0, 56f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 96f32, "x of node {:?}. Expected {}. Actual {}", node1, 96f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 136f32, "x of node {:?}. Expected {}. Actual {}", node2, 136f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 56f32, "x of node {:?}. Expected {}. Actual {}", node3, 56f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 96f32, "x of node {:?}. Expected {}. Actual {}", node4, 96f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 136f32, "x of node {:?}. Expected {}. Actual {}", node5, 136f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 56f32, "x of node {:?}. Expected {}. Actual {}", node6, 56f32, location.x); assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 96f32, "x of node {:?}. Expected {}. Actual {}", node7, 96f32, location.x); assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 136f32, "x of node {:?}. Expected {}. Actual {}", node8, 136f32, location.x); diff --git a/tests/generated/grid_justify_content_space_around.rs b/tests/generated/grid_justify_content_space_around.rs index 64f4a628b..7577cf9e0 100644 --- a/tests/generated/grid_justify_content_space_around.rs +++ b/tests/generated/grid_justify_content_space_around.rs @@ -3,81 +3,79 @@ fn grid_justify_content_space_around() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_content: Some(taffy::style::JustifyContent::SpaceAround), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceAround), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node0, 13f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 147f32, "x of node {:?}. Expected {}. Actual {}", node2, 147f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node3, 13f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 147f32, "x of node {:?}. Expected {}. Actual {}", node5, 147f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node6, 13f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 147f32, "x of node {:?}. Expected {}. Actual {}", node8, 147f32, location.x); diff --git a/tests/generated/grid_justify_content_space_around_with_padding_border.rs b/tests/generated/grid_justify_content_space_around_with_padding_border.rs index f7a2d8892..5c27506ee 100644 --- a/tests/generated/grid_justify_content_space_around_with_padding_border.rs +++ b/tests/generated/grid_justify_content_space_around_with_padding_border.rs @@ -3,93 +3,91 @@ fn grid_justify_content_space_around_with_padding_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_content: Some(taffy::style::JustifyContent::SpaceAround), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceAround), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 49f32, "x of node {:?}. Expected {}. Actual {}", node0, 49f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node1, 92f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node2, 135f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 49f32, "x of node {:?}. Expected {}. Actual {}", node3, 49f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node4, 92f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node5, 135f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 49f32, "x of node {:?}. Expected {}. Actual {}", node6, 49f32, location.x); assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node7, 92f32, location.x); assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node8, 135f32, location.x); diff --git a/tests/generated/grid_justify_content_space_between.rs b/tests/generated/grid_justify_content_space_between.rs index 0cb9375d4..2b61427df 100644 --- a/tests/generated/grid_justify_content_space_between.rs +++ b/tests/generated/grid_justify_content_space_between.rs @@ -3,81 +3,79 @@ fn grid_justify_content_space_between() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_content: Some(taffy::style::JustifyContent::SpaceBetween), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node2, 160f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node5, 160f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 160f32, "x of node {:?}. Expected {}. Actual {}", node8, 160f32, location.x); diff --git a/tests/generated/grid_justify_content_space_between_with_padding_border.rs b/tests/generated/grid_justify_content_space_between_with_padding_border.rs index 3bf647ad4..140759ba9 100644 --- a/tests/generated/grid_justify_content_space_between_with_padding_border.rs +++ b/tests/generated/grid_justify_content_space_between_with_padding_border.rs @@ -3,93 +3,91 @@ fn grid_justify_content_space_between_with_padding_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_content: Some(taffy::style::JustifyContent::SpaceBetween), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node1, 92f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 136f32, "x of node {:?}. Expected {}. Actual {}", node2, 136f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node4, 92f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 136f32, "x of node {:?}. Expected {}. Actual {}", node5, 136f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node7, 92f32, location.x); assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 136f32, "x of node {:?}. Expected {}. Actual {}", node8, 136f32, location.x); diff --git a/tests/generated/grid_justify_content_space_evenly.rs b/tests/generated/grid_justify_content_space_evenly.rs index 94f8833a4..79a71e663 100644 --- a/tests/generated/grid_justify_content_space_evenly.rs +++ b/tests/generated/grid_justify_content_space_evenly.rs @@ -3,81 +3,79 @@ fn grid_justify_content_space_evenly() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node2, 140f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node3, 20f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node5, 140f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node6, 20f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 140f32, "x of node {:?}. Expected {}. Actual {}", node8, 140f32, location.x); diff --git a/tests/generated/grid_justify_content_space_evenly_with_padding_border.rs b/tests/generated/grid_justify_content_space_evenly_with_padding_border.rs index 18762c8fe..2b20fa961 100644 --- a/tests/generated/grid_justify_content_space_evenly_with_padding_border.rs +++ b/tests/generated/grid_justify_content_space_evenly_with_padding_border.rs @@ -3,93 +3,91 @@ fn grid_justify_content_space_evenly_with_padding_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node1, 92f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 134f32, "x of node {:?}. Expected {}. Actual {}", node2, 134f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node4, 92f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 134f32, "x of node {:?}. Expected {}. Actual {}", node5, 134f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node6, 50f32, location.x); assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 92f32, "x of node {:?}. Expected {}. Actual {}", node7, 92f32, location.x); assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 134f32, "x of node {:?}. Expected {}. Actual {}", node8, 134f32, location.x); diff --git a/tests/generated/grid_justify_content_start.rs b/tests/generated/grid_justify_content_start.rs index b410af698..04bc80f24 100644 --- a/tests/generated/grid_justify_content_start.rs +++ b/tests/generated/grid_justify_content_start.rs @@ -3,81 +3,79 @@ fn grid_justify_content_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_content: Some(taffy::style::JustifyContent::Start), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::Start), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_justify_content_start_with_padding_border.rs b/tests/generated/grid_justify_content_start_with_padding_border.rs index 56c33c7c8..65d3b2650 100644 --- a/tests/generated/grid_justify_content_start_with_padding_border.rs +++ b/tests/generated/grid_justify_content_start_with_padding_border.rs @@ -3,93 +3,91 @@ fn grid_justify_content_start_with_padding_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_content: Some(taffy::style::JustifyContent::Start), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::Start), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node0, 48f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node1, 88f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node2, 128f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node2, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node3, 48f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node3, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node4, 88f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node4, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node5, 128f32, location.x); assert_eq!(location.y, 52f32, "y of node {:?}. Expected {}. Actual {}", node5, 52f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node6, 48f32, location.x); assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node6, 92f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 88f32, "x of node {:?}. Expected {}. Actual {}", node7, 88f32, location.x); assert_eq!(location.y, 92f32, "y of node {:?}. Expected {}. Actual {}", node7, 92f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node8, 128f32, location.x); diff --git a/tests/generated/grid_justify_items_sized_center.rs b/tests/generated/grid_justify_items_sized_center.rs index 603d88367..e8f1ca5e2 100644 --- a/tests/generated/grid_justify_items_sized_center.rs +++ b/tests/generated/grid_justify_items_sized_center.rs @@ -3,59 +3,53 @@ fn grid_justify_items_sized_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_items: Some(taffy::style::JustifyItems::Center), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_items: Some(taffy::style::JustifyItems::Center), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); diff --git a/tests/generated/grid_justify_items_sized_end.rs b/tests/generated/grid_justify_items_sized_end.rs index a7232c5b6..a2f43af8d 100644 --- a/tests/generated/grid_justify_items_sized_end.rs +++ b/tests/generated/grid_justify_items_sized_end.rs @@ -3,59 +3,53 @@ fn grid_justify_items_sized_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_items: Some(taffy::style::JustifyItems::End), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_items: Some(taffy::style::JustifyItems::End), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); diff --git a/tests/generated/grid_justify_items_sized_start.rs b/tests/generated/grid_justify_items_sized_start.rs index b269bcfbf..ab042b3a7 100644 --- a/tests/generated/grid_justify_items_sized_start.rs +++ b/tests/generated/grid_justify_items_sized_start.rs @@ -3,59 +3,53 @@ fn grid_justify_items_sized_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_items: Some(taffy::style::JustifyItems::Start), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_items: Some(taffy::style::JustifyItems::Start), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); diff --git a/tests/generated/grid_justify_items_sized_stretch.rs b/tests/generated/grid_justify_items_sized_stretch.rs index f6e9fc086..8c492dabf 100644 --- a/tests/generated/grid_justify_items_sized_stretch.rs +++ b/tests/generated/grid_justify_items_sized_stretch.rs @@ -3,59 +3,53 @@ fn grid_justify_items_sized_stretch() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_items: Some(taffy::style::JustifyItems::Stretch), + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(3i16), end: taffy::style::GridPlacement::Auto }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - justify_items: Some(taffy::style::JustifyItems::Stretch), - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); diff --git a/tests/generated/grid_justify_self_sized_all.rs b/tests/generated/grid_justify_self_sized_all.rs index b44a12921..87265e58c 100644 --- a/tests/generated/grid_justify_self_sized_all.rs +++ b/tests/generated/grid_justify_self_sized_all.rs @@ -3,146 +3,128 @@ fn grid_justify_self_sized_all() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - justify_self: Some(taffy::style::JustifySelf::Start), + let node0 = taffy.new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node6 = taffy.new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node7 = taffy.new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - justify_self: Some(taffy::style::JustifySelf::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - justify_self: Some(taffy::style::JustifySelf::End), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - justify_self: Some(taffy::style::JustifySelf::End), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - justify_self: Some(taffy::style::JustifySelf::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - justify_self: Some(taffy::style::JustifySelf::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node6 = taffy - .new_leaf(taffy::style::Style { - justify_self: Some(taffy::style::JustifySelf::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node7 = taffy - .new_leaf(taffy::style::Style { - justify_self: Some(taffy::style::JustifySelf::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node3, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node3, 60f32, size.height); assert_eq!(location.x, -20f32, "x of node {:?}. Expected {}. Actual {}", node3, -20f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node5, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node5, 70f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node7, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node7, 60f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); diff --git a/tests/generated/grid_margins_auto_margins.rs b/tests/generated/grid_margins_auto_margins.rs index 6b6562550..b00e77c90 100644 --- a/tests/generated/grid_margins_auto_margins.rs +++ b/tests/generated/grid_margins_auto_margins.rs @@ -3,122 +3,114 @@ fn grid_margins_auto_margins() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - justify_self: Some(taffy::style::JustifySelf::Start), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: taffy::style::LengthPercentageAuto::Length(0f32), - bottom: taffy::style::LengthPercentageAuto::Length(0f32), + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Length(0f32), + bottom: taffy::style::LengthPercentageAuto::Length(0f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(0f32), + right: taffy::style::LengthPercentageAuto::Length(0f32), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Start), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(0f32), - right: taffy::style::LengthPercentageAuto::Length(0f32), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, - }, - ..Default::default() - }) - .unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Start), - justify_self: Some(taffy::style::JustifySelf::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, - }, - ..Default::default() - }) - .unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 130f32, "x of node {:?}. Expected {}. Actual {}", node2, 130f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node4, 60f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node6, 50f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node6, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node8, 120f32, location.x); diff --git a/tests/generated/grid_margins_auto_margins_override_stretch.rs b/tests/generated/grid_margins_auto_margins_override_stretch.rs index b7fb01447..f2ddb1aba 100644 --- a/tests/generated/grid_margins_auto_margins_override_stretch.rs +++ b/tests/generated/grid_margins_auto_margins_override_stretch.rs @@ -3,106 +3,96 @@ fn grid_margins_auto_margins_override_stretch() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy - .new_leaf_with_measure( - taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Stretch), - justify_self: Some(taffy::style::JustifySelf::Stretch), - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + justify_self: Some(taffy::style::JustifySelf::Stretch), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node6, 10f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); assert_eq!(location.y, 105f32, "y of node {:?}. Expected {}. Actual {}", node6, 105f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node8, 120f32, location.x); diff --git a/tests/generated/grid_margins_fixed_center.rs b/tests/generated/grid_margins_fixed_center.rs index 08df514b6..19c8bf383 100644 --- a/tests/generated/grid_margins_fixed_center.rs +++ b/tests/generated/grid_margins_fixed_center.rs @@ -3,80 +3,76 @@ fn grid_margins_fixed_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Center), - justify_self: Some(taffy::style::JustifySelf::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(8f32), - right: taffy::style::LengthPercentageAuto::Length(4f32), - top: taffy::style::LengthPercentageAuto::Length(2f32), - bottom: taffy::style::LengthPercentageAuto::Length(6f32), + let node0 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(8f32), + right: taffy::style::LengthPercentageAuto::Length(4f32), + top: taffy::style::LengthPercentageAuto::Length(2f32), + bottom: taffy::style::LengthPercentageAuto::Length(6f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 52f32, "x of node {:?}. Expected {}. Actual {}", node0, 52f32, location.x); assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node0, 18f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); diff --git a/tests/generated/grid_margins_fixed_end.rs b/tests/generated/grid_margins_fixed_end.rs index e4177f1e7..c1883d308 100644 --- a/tests/generated/grid_margins_fixed_end.rs +++ b/tests/generated/grid_margins_fixed_end.rs @@ -3,80 +3,76 @@ fn grid_margins_fixed_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::End), - justify_self: Some(taffy::style::JustifySelf::End), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(3f32), + let node0 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(3f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 58f32, "x of node {:?}. Expected {}. Actual {}", node0, 58f32, location.x); assert_eq!(location.y, 27f32, "y of node {:?}. Expected {}. Actual {}", node0, 27f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); diff --git a/tests/generated/grid_margins_fixed_start.rs b/tests/generated/grid_margins_fixed_start.rs index a714cd415..b428806a1 100644 --- a/tests/generated/grid_margins_fixed_start.rs +++ b/tests/generated/grid_margins_fixed_start.rs @@ -3,80 +3,76 @@ fn grid_margins_fixed_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Start), - justify_self: Some(taffy::style::JustifySelf::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(3f32), + let node0 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(3f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 44f32, "x of node {:?}. Expected {}. Actual {}", node0, 44f32, location.x); assert_eq!(location.y, 11f32, "y of node {:?}. Expected {}. Actual {}", node0, 11f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); diff --git a/tests/generated/grid_margins_fixed_stretch.rs b/tests/generated/grid_margins_fixed_stretch.rs index 628afef32..e77f10847 100644 --- a/tests/generated/grid_margins_fixed_stretch.rs +++ b/tests/generated/grid_margins_fixed_stretch.rs @@ -3,80 +3,76 @@ fn grid_margins_fixed_stretch() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Stretch), - justify_self: Some(taffy::style::JustifySelf::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(4f32), - right: taffy::style::LengthPercentageAuto::Length(2f32), - top: taffy::style::LengthPercentageAuto::Length(1f32), - bottom: taffy::style::LengthPercentageAuto::Length(3f32), + let node0 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(4f32), + right: taffy::style::LengthPercentageAuto::Length(2f32), + top: taffy::style::LengthPercentageAuto::Length(1f32), + bottom: taffy::style::LengthPercentageAuto::Length(3f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(40f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(30f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(40f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(30f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 44f32, "x of node {:?}. Expected {}. Actual {}", node0, 44f32, location.x); assert_eq!(location.y, 11f32, "y of node {:?}. Expected {}. Actual {}", node0, 11f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node2, 120f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node5, 120f32, location.x); diff --git a/tests/generated/grid_margins_percent_center.rs b/tests/generated/grid_margins_percent_center.rs index fc8dd7bef..fd41ac28d 100644 --- a/tests/generated/grid_margins_percent_center.rs +++ b/tests/generated/grid_margins_percent_center.rs @@ -3,74 +3,70 @@ fn grid_margins_percent_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Center), - justify_self: Some(taffy::style::JustifySelf::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.2f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node0, 1f32, location.x); assert_eq!(location.y, 9f32, "y of node {:?}. Expected {}. Actual {}", node0, 9f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node4, 20f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); diff --git a/tests/generated/grid_margins_percent_end.rs b/tests/generated/grid_margins_percent_end.rs index 359d75b13..34ba1cbae 100644 --- a/tests/generated/grid_margins_percent_end.rs +++ b/tests/generated/grid_margins_percent_end.rs @@ -3,74 +3,70 @@ fn grid_margins_percent_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::End), - justify_self: Some(taffy::style::JustifySelf::End), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.2f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, -2f32, "x of node {:?}. Expected {}. Actual {}", node0, -2f32, location.x); assert_eq!(location.y, 17f32, "y of node {:?}. Expected {}. Actual {}", node0, 17f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node4, 20f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); diff --git a/tests/generated/grid_margins_percent_start.rs b/tests/generated/grid_margins_percent_start.rs index fa73ec6d3..5b2129b44 100644 --- a/tests/generated/grid_margins_percent_start.rs +++ b/tests/generated/grid_margins_percent_start.rs @@ -3,74 +3,70 @@ fn grid_margins_percent_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Start), - justify_self: Some(taffy::style::JustifySelf::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.2f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node4, 20f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); diff --git a/tests/generated/grid_margins_percent_stretch.rs b/tests/generated/grid_margins_percent_stretch.rs index 37d9d6fe0..8e9a057d9 100644 --- a/tests/generated/grid_margins_percent_stretch.rs +++ b/tests/generated/grid_margins_percent_stretch.rs @@ -3,74 +3,70 @@ fn grid_margins_percent_stretch() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Stretch), - justify_self: Some(taffy::style::JustifySelf::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.2f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(20f32), length(20f32), length(20f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node0, 4f32, location.x); assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node4, 20f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); diff --git a/tests/generated/grid_max_content_maximum_single_item.rs b/tests/generated/grid_max_content_maximum_single_item.rs index fb99480ae..056c05f29 100644 --- a/tests/generated/grid_max_content_maximum_single_item.rs +++ b/tests/generated/grid_max_content_maximum_single_item.rs @@ -3,90 +3,80 @@ fn grid_max_content_maximum_single_item() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), minmax(length(0f32), max_content()), length(40f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), minmax(length(0f32), max_content()), length(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_max_content_single_item.rs b/tests/generated/grid_max_content_single_item.rs index 65872afd0..04d1bb729 100644 --- a/tests/generated/grid_max_content_single_item.rs +++ b/tests/generated/grid_max_content_single_item.rs @@ -3,90 +3,80 @@ fn grid_max_content_single_item() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), max_content(), length(40f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), max_content(), length(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_max_content_single_item_margin_auto.rs b/tests/generated/grid_max_content_single_item_margin_auto.rs index 5731e5959..3551e2712 100644 --- a/tests/generated/grid_max_content_single_item_margin_auto.rs +++ b/tests/generated/grid_max_content_single_item_margin_auto.rs @@ -3,98 +3,88 @@ fn grid_max_content_single_item_margin_auto() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), max_content(), length(40f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), max_content(), length(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node1, 15f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_max_content_single_item_margin_fixed.rs b/tests/generated/grid_max_content_single_item_margin_fixed.rs index fdf5aad9f..a04aa422a 100644 --- a/tests/generated/grid_max_content_single_item_margin_fixed.rs +++ b/tests/generated/grid_max_content_single_item_margin_fixed.rs @@ -3,98 +3,88 @@ fn grid_max_content_single_item_margin_fixed() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(20f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(15f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(20f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(15f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), max_content(), length(40f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), max_content(), length(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node2, 110f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node4, 70f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node5, 110f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node7, 70f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node8, 110f32, location.x); diff --git a/tests/generated/grid_max_content_single_item_margin_percent.rs b/tests/generated/grid_max_content_single_item_margin_percent.rs index e7aed84fc..b514675e0 100644 --- a/tests/generated/grid_max_content_single_item_margin_percent.rs +++ b/tests/generated/grid_max_content_single_item_margin_percent.rs @@ -3,98 +3,88 @@ fn grid_max_content_single_item_margin_percent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.2f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), max_content(), length(40f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), max_content(), length(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node1, 28f32, size.width); assert_eq!(size.height, 32f32, "height of node {:?}. Expected {}. Actual {}", node1, 32f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node1, 48f32, location.x); assert_eq!(location.y, 2f32, "y of node {:?}. Expected {}. Actual {}", node1, 2f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_max_content_single_item_span_2.rs b/tests/generated/grid_max_content_single_item_span_2.rs index 5e28a7b60..dfbefb763 100644 --- a/tests/generated/grid_max_content_single_item_span_2.rs +++ b/tests/generated/grid_max_content_single_item_span_2.rs @@ -3,96 +3,86 @@ fn grid_max_content_single_item_span_2() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_column: taffy::geometry::Line { - start: taffy::style::GridPlacement::Span(2u16), - end: taffy::style::GridPlacement::Auto, - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), max_content(), max_content()], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), max_content(), max_content()], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node4, 60f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node7, 60f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); diff --git a/tests/generated/grid_max_content_single_item_span_2_gap_fixed.rs b/tests/generated/grid_max_content_single_item_span_2_gap_fixed.rs index 506bb2cdb..98d344d0d 100644 --- a/tests/generated/grid_max_content_single_item_span_2_gap_fixed.rs +++ b/tests/generated/grid_max_content_single_item_span_2_gap_fixed.rs @@ -3,97 +3,87 @@ fn grid_max_content_single_item_span_2_gap_fixed() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_column: taffy::geometry::Line { - start: taffy::style::GridPlacement::Span(2u16), - end: taffy::style::GridPlacement::Auto, - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(20f32), height: zero() }, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), max_content(), max_content()], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Length(20f32), height: zero() }, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), max_content(), max_content()], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node6, 60f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node7, 100f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); diff --git a/tests/generated/grid_max_content_single_item_span_2_gap_percent_definite.rs b/tests/generated/grid_max_content_single_item_span_2_gap_percent_definite.rs index 0481e9a7e..097d4ec5a 100644 --- a/tests/generated/grid_max_content_single_item_span_2_gap_percent_definite.rs +++ b/tests/generated/grid_max_content_single_item_span_2_gap_percent_definite.rs @@ -3,98 +3,88 @@ fn grid_max_content_single_item_span_2_gap_percent_definite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_column: taffy::geometry::Line { - start: taffy::style::GridPlacement::Span(2u16), - end: taffy::style::GridPlacement::Auto, - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), max_content(), max_content()], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), max_content(), max_content()], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node6, 60f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node7, 100f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); diff --git a/tests/generated/grid_max_content_single_item_span_2_gap_percent_indefinite.rs b/tests/generated/grid_max_content_single_item_span_2_gap_percent_indefinite.rs index c7cbad15d..2ec39e2c9 100644 --- a/tests/generated/grid_max_content_single_item_span_2_gap_percent_indefinite.rs +++ b/tests/generated/grid_max_content_single_item_span_2_gap_percent_indefinite.rs @@ -3,97 +3,87 @@ fn grid_max_content_single_item_span_2_gap_percent_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_column: taffy::geometry::Line { - start: taffy::style::GridPlacement::Span(2u16), - end: taffy::style::GridPlacement::Auto, - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), max_content(), max_content()], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), max_content(), max_content()], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node3, 60f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node4, 100f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node6, 60f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node7, 100f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node8, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); diff --git a/tests/generated/grid_min_content_flex_column.rs b/tests/generated/grid_min_content_flex_column.rs index 91d107424..7a648a8e8 100644 --- a/tests/generated/grid_min_content_flex_column.rs +++ b/tests/generated/grid_min_content_flex_column.rs @@ -3,97 +3,69 @@ fn grid_min_content_flex_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node01 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node02 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - ..Default::default() - }, - &[node00, node01, node02], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![min_content()], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node00 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node01 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node02 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + ..Default::default() + }, + &[node00, node01, node02], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![min_content()], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node02).unwrap(); + let Layout { size, location, .. } = taffy.layout(node02); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); diff --git a/tests/generated/grid_min_content_flex_row.rs b/tests/generated/grid_min_content_flex_row.rs index b506ab545..9a1ab36d0 100644 --- a/tests/generated/grid_min_content_flex_row.rs +++ b/tests/generated/grid_min_content_flex_row.rs @@ -3,93 +3,65 @@ fn grid_min_content_flex_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node01 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node02 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Flex, ..Default::default() }, - &[node00, node01, node02], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![min_content()], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node00 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node01 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node02 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node0 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Flex, ..Default::default() }, + &[node00, node01, node02], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![min_content()], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node02).unwrap(); + let Layout { size, location, .. } = taffy.layout(node02); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node02, 40f32, location.x); diff --git a/tests/generated/grid_min_content_flex_single_item.rs b/tests/generated/grid_min_content_flex_single_item.rs index 320abc2fd..4e8a84af7 100644 --- a/tests/generated/grid_min_content_flex_single_item.rs +++ b/tests/generated/grid_min_content_flex_single_item.rs @@ -3,95 +3,83 @@ fn grid_min_content_flex_single_item() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_column: taffy::geometry::Line { - start: taffy::style::GridPlacement::Span(2u16), - end: taffy::style::GridPlacement::Auto, - }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, }, - &[node0, node1, node2, node3, node4, node5, node6, node7], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node6, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node7, 50f32, location.x); diff --git a/tests/generated/grid_min_content_flex_single_item_margin_auto.rs b/tests/generated/grid_min_content_flex_single_item_margin_auto.rs index c27b3e292..99d7e9dfa 100644 --- a/tests/generated/grid_min_content_flex_single_item_margin_auto.rs +++ b/tests/generated/grid_min_content_flex_single_item_margin_auto.rs @@ -3,10 +3,25 @@ fn grid_min_content_flex_single_item_margin_auto() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Auto, right: taffy::style::LengthPercentageAuto::Auto, @@ -14,96 +29,69 @@ fn grid_min_content_flex_single_item_margin_auto() { bottom: taffy::style::LengthPercentageAuto::Auto, }, ..Default::default() - }) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_column: taffy::geometry::Line { - start: taffy::style::GridPlacement::Span(2u16), - end: taffy::style::GridPlacement::Auto, - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, - }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node4, 55f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node6, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node7, 50f32, location.x); diff --git a/tests/generated/grid_min_content_flex_single_item_margin_fixed.rs b/tests/generated/grid_min_content_flex_single_item_margin_fixed.rs index 2f50dd5db..bd18d4bc2 100644 --- a/tests/generated/grid_min_content_flex_single_item_margin_fixed.rs +++ b/tests/generated/grid_min_content_flex_single_item_margin_fixed.rs @@ -3,10 +3,25 @@ fn grid_min_content_flex_single_item_margin_fixed() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(20f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(15f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Length(20f32), right: taffy::style::LengthPercentageAuto::Length(10f32), @@ -14,96 +29,69 @@ fn grid_min_content_flex_single_item_margin_fixed() { bottom: taffy::style::LengthPercentageAuto::Length(15f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_column: taffy::geometry::Line { - start: taffy::style::GridPlacement::Span(2u16), - end: taffy::style::GridPlacement::Auto, - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(20f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(15f32), - }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node4, 60f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node4, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node7, 80f32, location.x); diff --git a/tests/generated/grid_min_content_flex_single_item_margin_percent.rs b/tests/generated/grid_min_content_flex_single_item_margin_percent.rs index 49bca1e4c..3714ace85 100644 --- a/tests/generated/grid_min_content_flex_single_item_margin_percent.rs +++ b/tests/generated/grid_min_content_flex_single_item_margin_percent.rs @@ -3,10 +3,25 @@ fn grid_min_content_flex_single_item_margin_percent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Percent(0.2f32), right: taffy::style::LengthPercentageAuto::Percent(0.1f32), @@ -14,96 +29,69 @@ fn grid_min_content_flex_single_item_margin_percent() { bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_column: taffy::geometry::Line { - start: taffy::style::GridPlacement::Span(2u16), - end: taffy::style::GridPlacement::Auto, - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.2f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), - }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), min_content(), fr(1f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 38f32, "height of node {:?}. Expected {}. Actual {}", node1, 38f32, size.height); assert_eq!(location.x, 42f32, "x of node {:?}. Expected {}. Actual {}", node1, 42f32, location.x); assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node1, 1f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node4, 28f32, size.width); assert_eq!(size.height, 32f32, "height of node {:?}. Expected {}. Actual {}", node4, 32f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node4, 48f32, location.x); assert_eq!(location.y, 42f32, "y of node {:?}. Expected {}. Actual {}", node4, 42f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node6, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node7, 50f32, location.x); diff --git a/tests/generated/grid_min_content_maximum_single_item.rs b/tests/generated/grid_min_content_maximum_single_item.rs index 81420a4f1..9acd8b8ab 100644 --- a/tests/generated/grid_min_content_maximum_single_item.rs +++ b/tests/generated/grid_min_content_maximum_single_item.rs @@ -3,90 +3,80 @@ fn grid_min_content_maximum_single_item() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), minmax(length(0f32), min_content()), length(40f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), minmax(length(0f32), min_content()), length(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); diff --git a/tests/generated/grid_min_content_single_item.rs b/tests/generated/grid_min_content_single_item.rs index 1735f86c6..0300db382 100644 --- a/tests/generated/grid_min_content_single_item.rs +++ b/tests/generated/grid_min_content_single_item.rs @@ -3,90 +3,80 @@ fn grid_min_content_single_item() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), min_content(), length(40f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), min_content(), length(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); diff --git a/tests/generated/grid_minmax_auto_fixed_10px.rs b/tests/generated/grid_minmax_auto_fixed_10px.rs index 15079c725..190668340 100644 --- a/tests/generated/grid_minmax_auto_fixed_10px.rs +++ b/tests/generated/grid_minmax_auto_fixed_10px.rs @@ -3,42 +3,32 @@ fn grid_minmax_auto_fixed_10px() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(auto(), length(10f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(auto(), length(10f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_auto_max_content.rs b/tests/generated/grid_minmax_auto_max_content.rs index 548abde48..e742ccd4e 100644 --- a/tests/generated/grid_minmax_auto_max_content.rs +++ b/tests/generated/grid_minmax_auto_max_content.rs @@ -3,42 +3,32 @@ fn grid_minmax_auto_max_content() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(auto(), max_content())], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(auto(), max_content())], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_auto_min_content.rs b/tests/generated/grid_minmax_auto_min_content.rs index c2a03a025..7e13898ae 100644 --- a/tests/generated/grid_minmax_auto_min_content.rs +++ b/tests/generated/grid_minmax_auto_min_content.rs @@ -3,42 +3,32 @@ fn grid_minmax_auto_min_content() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(auto(), min_content())], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(auto(), min_content())], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_auto_percent_definite.rs b/tests/generated/grid_minmax_auto_percent_definite.rs index 88729428b..2906bac3c 100644 --- a/tests/generated/grid_minmax_auto_percent_definite.rs +++ b/tests/generated/grid_minmax_auto_percent_definite.rs @@ -3,43 +3,33 @@ fn grid_minmax_auto_percent_definite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(auto(), percent(0.2f32))], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(auto(), percent(0.2f32))], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_auto_percent_indefinite.rs b/tests/generated/grid_minmax_auto_percent_indefinite.rs index 3d6fd04bf..b5b0075b4 100644 --- a/tests/generated/grid_minmax_auto_percent_indefinite.rs +++ b/tests/generated/grid_minmax_auto_percent_indefinite.rs @@ -3,42 +3,32 @@ fn grid_minmax_auto_percent_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(auto(), percent(0.2f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(auto(), percent(0.2f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 8f32, "width of node {:?}. Expected {}. Actual {}", node0, 8f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_column_fixed_width_above_range.rs b/tests/generated/grid_minmax_column_fixed_width_above_range.rs index c295dcf9a..eb1097a17 100644 --- a/tests/generated/grid_minmax_column_fixed_width_above_range.rs +++ b/tests/generated/grid_minmax_column_fixed_width_above_range.rs @@ -3,77 +3,75 @@ fn grid_minmax_column_fixed_width_above_range() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(140f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(140f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node, 140f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_minmax_column_fixed_width_below_range.rs b/tests/generated/grid_minmax_column_fixed_width_below_range.rs index 063049827..4d35fddb6 100644 --- a/tests/generated/grid_minmax_column_fixed_width_below_range.rs +++ b/tests/generated/grid_minmax_column_fixed_width_below_range.rs @@ -3,77 +3,75 @@ fn grid_minmax_column_fixed_width_below_range() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(90f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(90f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node, 90f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x); diff --git a/tests/generated/grid_minmax_column_fixed_width_within_range.rs b/tests/generated/grid_minmax_column_fixed_width_within_range.rs index 9539e18b7..ea9a29b2f 100644 --- a/tests/generated/grid_minmax_column_fixed_width_within_range.rs +++ b/tests/generated/grid_minmax_column_fixed_width_within_range.rs @@ -3,77 +3,75 @@ fn grid_minmax_column_fixed_width_within_range() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(110f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(110f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node5, 70f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node7, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node8, 70f32, location.x); diff --git a/tests/generated/grid_minmax_column_indefinite.rs b/tests/generated/grid_minmax_column_indefinite.rs index 5b8e516b5..68cf06249 100644 --- a/tests/generated/grid_minmax_column_indefinite.rs +++ b/tests/generated/grid_minmax_column_indefinite.rs @@ -3,76 +3,74 @@ fn grid_minmax_column_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), minmax(length(20f32), length(40f32)), length(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_minmax_column_with_auto_fixed.rs b/tests/generated/grid_minmax_column_with_auto_fixed.rs index f53ee3950..544d2307c 100644 --- a/tests/generated/grid_minmax_column_with_auto_fixed.rs +++ b/tests/generated/grid_minmax_column_with_auto_fixed.rs @@ -3,35 +3,33 @@ fn grid_minmax_column_with_auto_fixed() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(length(20f32), length(40f32)), auto()], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(length(20f32), length(40f32)), auto()], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); diff --git a/tests/generated/grid_minmax_column_with_fr_fixed.rs b/tests/generated/grid_minmax_column_with_fr_fixed.rs index 5564e222a..d669484ee 100644 --- a/tests/generated/grid_minmax_column_with_fr_fixed.rs +++ b/tests/generated/grid_minmax_column_with_fr_fixed.rs @@ -3,35 +3,33 @@ fn grid_minmax_column_with_fr_fixed() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(length(20f32), length(40f32)), fr(1f32)], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(length(20f32), length(40f32)), fr(1f32)], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); diff --git a/tests/generated/grid_minmax_max_content_1fr.rs b/tests/generated/grid_minmax_max_content_1fr.rs index fb96cd14e..83031c406 100644 --- a/tests/generated/grid_minmax_max_content_1fr.rs +++ b/tests/generated/grid_minmax_max_content_1fr.rs @@ -3,42 +3,32 @@ fn grid_minmax_max_content_1fr() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(max_content(), fr(1f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(max_content(), fr(1f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_max_content_auto.rs b/tests/generated/grid_minmax_max_content_auto.rs index c2ee7d4f9..bd951c503 100644 --- a/tests/generated/grid_minmax_max_content_auto.rs +++ b/tests/generated/grid_minmax_max_content_auto.rs @@ -3,42 +3,32 @@ fn grid_minmax_max_content_auto() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(max_content(), auto())], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(max_content(), auto())], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_max_content_fixed_10px.rs b/tests/generated/grid_minmax_max_content_fixed_10px.rs index 3ac6bb7bc..bc468c795 100644 --- a/tests/generated/grid_minmax_max_content_fixed_10px.rs +++ b/tests/generated/grid_minmax_max_content_fixed_10px.rs @@ -3,42 +3,32 @@ fn grid_minmax_max_content_fixed_10px() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(max_content(), length(10f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(max_content(), length(10f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_max_content_min_content.rs b/tests/generated/grid_minmax_max_content_min_content.rs index 9d9f252c1..23e52a91d 100644 --- a/tests/generated/grid_minmax_max_content_min_content.rs +++ b/tests/generated/grid_minmax_max_content_min_content.rs @@ -3,42 +3,32 @@ fn grid_minmax_max_content_min_content() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(max_content(), min_content())], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(max_content(), min_content())], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_max_content_percent_definite.rs b/tests/generated/grid_minmax_max_content_percent_definite.rs index 2cd62dd6f..5b89d35f6 100644 --- a/tests/generated/grid_minmax_max_content_percent_definite.rs +++ b/tests/generated/grid_minmax_max_content_percent_definite.rs @@ -3,43 +3,33 @@ fn grid_minmax_max_content_percent_definite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(max_content(), percent(0.2f32))], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(max_content(), percent(0.2f32))], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_max_content_percent_indefinite.rs b/tests/generated/grid_minmax_max_content_percent_indefinite.rs index bd45de88d..87c68449c 100644 --- a/tests/generated/grid_minmax_max_content_percent_indefinite.rs +++ b/tests/generated/grid_minmax_max_content_percent_indefinite.rs @@ -3,42 +3,32 @@ fn grid_minmax_max_content_percent_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(max_content(), percent(0.2f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(max_content(), percent(0.2f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_min_content_1fr.rs b/tests/generated/grid_minmax_min_content_1fr.rs index 94c348e92..ce4483304 100644 --- a/tests/generated/grid_minmax_min_content_1fr.rs +++ b/tests/generated/grid_minmax_min_content_1fr.rs @@ -3,42 +3,32 @@ fn grid_minmax_min_content_1fr() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(min_content(), fr(1f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(min_content(), fr(1f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_min_content_auto.rs b/tests/generated/grid_minmax_min_content_auto.rs index 99b6f05da..16cf4e98e 100644 --- a/tests/generated/grid_minmax_min_content_auto.rs +++ b/tests/generated/grid_minmax_min_content_auto.rs @@ -3,42 +3,32 @@ fn grid_minmax_min_content_auto() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(min_content(), auto())], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(min_content(), auto())], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_min_content_fixed_10px.rs b/tests/generated/grid_minmax_min_content_fixed_10px.rs index 18334bc09..41fdd14f6 100644 --- a/tests/generated/grid_minmax_min_content_fixed_10px.rs +++ b/tests/generated/grid_minmax_min_content_fixed_10px.rs @@ -3,42 +3,32 @@ fn grid_minmax_min_content_fixed_10px() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(min_content(), length(10f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(min_content(), length(10f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_min_content_max_content.rs b/tests/generated/grid_minmax_min_content_max_content.rs index ad7e44fc8..0e3d67b8b 100644 --- a/tests/generated/grid_minmax_min_content_max_content.rs +++ b/tests/generated/grid_minmax_min_content_max_content.rs @@ -3,42 +3,32 @@ fn grid_minmax_min_content_max_content() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(min_content(), max_content())], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(min_content(), max_content())], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_min_content_percent_definite.rs b/tests/generated/grid_minmax_min_content_percent_definite.rs index 5b86025d0..7b0a57669 100644 --- a/tests/generated/grid_minmax_min_content_percent_definite.rs +++ b/tests/generated/grid_minmax_min_content_percent_definite.rs @@ -3,43 +3,33 @@ fn grid_minmax_min_content_percent_definite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(min_content(), percent(0.2f32))], - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(min_content(), percent(0.2f32))], + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_minmax_min_content_percent_indefinite.rs b/tests/generated/grid_minmax_min_content_percent_indefinite.rs index 3f93e492d..7d1994e67 100644 --- a/tests/generated/grid_minmax_min_content_percent_indefinite.rs +++ b/tests/generated/grid_minmax_min_content_percent_indefinite.rs @@ -3,42 +3,32 @@ fn grid_minmax_min_content_percent_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![minmax(min_content(), percent(0.2f32))], - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![minmax(min_content(), percent(0.2f32))], + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_out_of_order_items.rs b/tests/generated/grid_out_of_order_items.rs index a95f7f863..87c7b4ba7 100644 --- a/tests/generated/grid_out_of_order_items.rs +++ b/tests/generated/grid_out_of_order_items.rs @@ -3,109 +3,101 @@ fn grid_out_of_order_items() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(35f32), + height: taffy::style::Dimension::Length(35f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + grid_auto_flow: taffy::style::GridAutoFlow::RowDense, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(35f32), - height: taffy::style::Dimension::Length(35f32), + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, ..Default::default() - }) - .unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - grid_auto_flow: taffy::style::GridAutoFlow::RowDense, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node2, 35f32, size.width); assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node2, 35f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node2, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node3, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node4, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node6, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node7, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node7, 10f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node7, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_overflow_inline_axis_hidden.rs b/tests/generated/grid_overflow_inline_axis_hidden.rs index 268fe6b98..6560364bc 100644 --- a/tests/generated/grid_overflow_inline_axis_hidden.rs +++ b/tests/generated/grid_overflow_inline_axis_hidden.rs @@ -3,51 +3,38 @@ fn grid_overflow_inline_axis_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_overflow_inline_axis_scroll.rs b/tests/generated/grid_overflow_inline_axis_scroll.rs index 6429c2509..e110ac674 100644 --- a/tests/generated/grid_overflow_inline_axis_scroll.rs +++ b/tests/generated/grid_overflow_inline_axis_scroll.rs @@ -3,51 +3,38 @@ fn grid_overflow_inline_axis_scroll() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_overflow_inline_axis_visible.rs b/tests/generated/grid_overflow_inline_axis_visible.rs index fc400e473..9c6fcdc13 100644 --- a/tests/generated/grid_overflow_inline_axis_visible.rs +++ b/tests/generated/grid_overflow_inline_axis_visible.rs @@ -3,44 +3,34 @@ fn grid_overflow_inline_axis_visible() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_overflow_rows.rs b/tests/generated/grid_overflow_rows.rs index 4dd5fc7a0..f33b55e6f 100644 --- a/tests/generated/grid_overflow_rows.rs +++ b/tests/generated/grid_overflow_rows.rs @@ -3,75 +3,65 @@ fn grid_overflow_rows() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(4u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32)], - grid_template_columns: vec![min_content(), max_content(), length(10f32), percent(0.2f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(4u16) }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32)], + grid_template_columns: vec![min_content(), max_content(), length(10f32), percent(0.2f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 43f32, "width of node {:?}. Expected {}. Actual {}", node1, 43f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 203f32, "width of node {:?}. Expected {}. Actual {}", node2, 203f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 43f32, "x of node {:?}. Expected {}. Actual {}", node2, 43f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node3, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 246f32, "x of node {:?}. Expected {}. Actual {}", node3, 246f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 64f32, "width of node {:?}. Expected {}. Actual {}", node4, 64f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 256f32, "x of node {:?}. Expected {}. Actual {}", node4, 256f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 43f32, "width of node {:?}. Expected {}. Actual {}", node5, 43f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); diff --git a/tests/generated/grid_overflow_scrollbars_overriden_by_available_space.rs b/tests/generated/grid_overflow_scrollbars_overriden_by_available_space.rs index d163bd960..ceb7ba986 100644 --- a/tests/generated/grid_overflow_scrollbars_overriden_by_available_space.rs +++ b/tests/generated/grid_overflow_scrollbars_overriden_by_available_space.rs @@ -3,49 +3,42 @@ fn grid_overflow_scrollbars_overriden_by_available_space() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - ..Default::default() + let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(4f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(4f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node0, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/grid_overflow_scrollbars_overriden_by_max_size.rs b/tests/generated/grid_overflow_scrollbars_overriden_by_max_size.rs index 11911947b..056341717 100644 --- a/tests/generated/grid_overflow_scrollbars_overriden_by_max_size.rs +++ b/tests/generated/grid_overflow_scrollbars_overriden_by_max_size.rs @@ -3,35 +3,30 @@ fn grid_overflow_scrollbars_overriden_by_max_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(4f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(4f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_overflow_scrollbars_overriden_by_size.rs b/tests/generated/grid_overflow_scrollbars_overriden_by_size.rs index 46368c9a7..c9144d626 100644 --- a/tests/generated/grid_overflow_scrollbars_overriden_by_size.rs +++ b/tests/generated/grid_overflow_scrollbars_overriden_by_size.rs @@ -3,35 +3,30 @@ fn grid_overflow_scrollbars_overriden_by_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(4f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(4f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_overflow_scrollbars_take_up_space_both_axis.rs b/tests/generated/grid_overflow_scrollbars_take_up_space_both_axis.rs index a87ea6cdf..38d86dd00 100644 --- a/tests/generated/grid_overflow_scrollbars_take_up_space_both_axis.rs +++ b/tests/generated/grid_overflow_scrollbars_take_up_space_both_axis.rs @@ -3,35 +3,30 @@ fn grid_overflow_scrollbars_take_up_space_both_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_overflow_scrollbars_take_up_space_x_axis.rs b/tests/generated/grid_overflow_scrollbars_take_up_space_x_axis.rs index 2dc411f90..9341be831 100644 --- a/tests/generated/grid_overflow_scrollbars_take_up_space_x_axis.rs +++ b/tests/generated/grid_overflow_scrollbars_take_up_space_x_axis.rs @@ -3,35 +3,30 @@ fn grid_overflow_scrollbars_take_up_space_x_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Visible, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Visible }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_overflow_scrollbars_take_up_space_y_axis.rs b/tests/generated/grid_overflow_scrollbars_take_up_space_y_axis.rs index 085b8534d..6281a5e89 100644 --- a/tests/generated/grid_overflow_scrollbars_take_up_space_y_axis.rs +++ b/tests/generated/grid_overflow_scrollbars_take_up_space_y_axis.rs @@ -3,35 +3,30 @@ fn grid_overflow_scrollbars_take_up_space_y_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Visible, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_padding_border_overrides_container_max_size.rs b/tests/generated/grid_padding_border_overrides_container_max_size.rs index 120669afa..af04f69b7 100644 --- a/tests/generated/grid_padding_border_overrides_container_max_size.rs +++ b/tests/generated/grid_padding_border_overrides_container_max_size.rs @@ -3,42 +3,40 @@ fn grid_padding_border_overrides_container_max_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); diff --git a/tests/generated/grid_padding_border_overrides_container_size.rs b/tests/generated/grid_padding_border_overrides_container_size.rs index c17647204..ca7ccd17e 100644 --- a/tests/generated/grid_padding_border_overrides_container_size.rs +++ b/tests/generated/grid_padding_border_overrides_container_size.rs @@ -3,42 +3,40 @@ fn grid_padding_border_overrides_container_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0, 15f32, location.x); diff --git a/tests/generated/grid_padding_border_overrides_max_size.rs b/tests/generated/grid_padding_border_overrides_max_size.rs index df6a4a772..15df35656 100644 --- a/tests/generated/grid_padding_border_overrides_max_size.rs +++ b/tests/generated/grid_padding_border_overrides_max_size.rs @@ -3,40 +3,39 @@ fn grid_padding_border_overrides_max_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children(taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, &[node0]) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_padding_border_overrides_min_size.rs b/tests/generated/grid_padding_border_overrides_min_size.rs index 5e3d75471..d95c67052 100644 --- a/tests/generated/grid_padding_border_overrides_min_size.rs +++ b/tests/generated/grid_padding_border_overrides_min_size.rs @@ -3,40 +3,39 @@ fn grid_padding_border_overrides_min_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(0f32), - height: taffy::style::Dimension::Length(0f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children(taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, &[node0]) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(0f32), + height: taffy::style::Dimension::Length(0f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_padding_border_overrides_size.rs b/tests/generated/grid_padding_border_overrides_size.rs index 380ecf3b8..04a29680f 100644 --- a/tests/generated/grid_padding_border_overrides_size.rs +++ b/tests/generated/grid_padding_border_overrides_size.rs @@ -3,40 +3,39 @@ fn grid_padding_border_overrides_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children(taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, &[node0]) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_percent_item_inside_stretch_item.rs b/tests/generated/grid_percent_item_inside_stretch_item.rs index 3c76b4356..3d18f3f65 100644 --- a/tests/generated/grid_percent_item_inside_stretch_item.rs +++ b/tests/generated/grid_percent_item_inside_stretch_item.rs @@ -3,47 +3,41 @@ fn grid_percent_item_inside_stretch_item() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/grid_percent_items_nested_inside_stretch_alignment.rs b/tests/generated/grid_percent_items_nested_inside_stretch_alignment.rs index 12a720c01..776408b48 100644 --- a/tests/generated/grid_percent_items_nested_inside_stretch_alignment.rs +++ b/tests/generated/grid_percent_items_nested_inside_stretch_alignment.rs @@ -3,49 +3,43 @@ fn grid_percent_items_nested_inside_stretch_alignment() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + display: taffy::style::Display::Grid, + padding: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentage::Percent(0.2f32), + bottom: zero(), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, - padding: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentage::Percent(0.2f32), - bottom: zero(), - }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node00, 200f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/grid_percent_items_nested_moderate.rs b/tests/generated/grid_percent_items_nested_moderate.rs index aa8a12d03..91a131c1d 100644 --- a/tests/generated/grid_percent_items_nested_moderate.rs +++ b/tests/generated/grid_percent_items_nested_moderate.rs @@ -4,15 +4,46 @@ fn grid_percent_items_nested_moderate() { use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); taffy.disable_rounding(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(3f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(3f32), + bottom: taffy::style::LengthPercentage::Length(3f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: taffy::style::LengthPercentageAuto::Percent(0.05f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Percent(0.03f32), + right: taffy::style::LengthPercentage::Percent(0.03f32), + top: taffy::style::LengthPercentage::Percent(0.03f32), + bottom: taffy::style::LengthPercentage::Percent(0.03f32), + }, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Length(3f32), right: taffy::style::LengthPercentage::Length(3f32), @@ -20,51 +51,14 @@ fn grid_percent_items_nested_moderate() { bottom: taffy::style::LengthPercentage::Length(3f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Percent(0.03f32), - right: taffy::style::LengthPercentage::Percent(0.03f32), - top: taffy::style::LengthPercentage::Percent(0.03f32), - bottom: taffy::style::LengthPercentage::Percent(0.03f32), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(3f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(3f32), - bottom: taffy::style::LengthPercentage::Length(3f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert!(size.width - 200f32 < 0.1, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert!( size.height - 42.15625f32 < 0.1, @@ -75,7 +69,7 @@ fn grid_percent_items_nested_moderate() { ); assert!(location.x - 0f32 < 0.1, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert!(location.y - 0f32 < 0.1, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert!(size.width - 97f32 < 0.1, "width of node {:?}. Expected {}. Actual {}", node0, 97f32, size.width); assert!( size.height - 26.15625f32 < 0.1, @@ -86,12 +80,12 @@ fn grid_percent_items_nested_moderate() { ); assert!(location.x - 8f32 < 0.1, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); assert!(location.y - 8f32 < 0.1, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert!( - size.width - 38.414063f32 < 0.1, + size.width - 38.40625f32 < 0.1, "width of node {:?}. Expected {}. Actual {}", node00, - 38.414063f32, + 38.40625f32, size.width ); assert!(size.height - 6f32 < 0.1, "height of node {:?}. Expected {}. Actual {}", node00, 6f32, size.height); diff --git a/tests/generated/grid_percent_items_nested_with_margin.rs b/tests/generated/grid_percent_items_nested_with_margin.rs index 99358e50a..dcfff0527 100644 --- a/tests/generated/grid_percent_items_nested_with_margin.rs +++ b/tests/generated/grid_percent_items_nested_with_margin.rs @@ -3,53 +3,47 @@ fn grid_percent_items_nested_with_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: taffy::style::LengthPercentageAuto::Percent(0.05f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node00, 45f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x); diff --git a/tests/generated/grid_percent_items_nested_with_padding_margin.rs b/tests/generated/grid_percent_items_nested_with_padding_margin.rs index 2f671d62d..8d5572985 100644 --- a/tests/generated/grid_percent_items_nested_with_padding_margin.rs +++ b/tests/generated/grid_percent_items_nested_with_padding_margin.rs @@ -3,14 +3,51 @@ fn grid_percent_items_nested_with_padding_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() }, + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(3f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(3f32), + bottom: taffy::style::LengthPercentage::Length(3f32), + }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: taffy::style::LengthPercentageAuto::Percent(0.05f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Percent(0.03f32), + right: taffy::style::LengthPercentage::Percent(0.03f32), + top: taffy::style::LengthPercentage::Percent(0.03f32), + bottom: taffy::style::LengthPercentage::Percent(0.03f32), + }, + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Length(3f32), @@ -19,92 +56,47 @@ fn grid_percent_items_nested_with_padding_margin() { bottom: taffy::style::LengthPercentage::Length(3f32), }, ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Percent(0.03f32), - right: taffy::style::LengthPercentage::Percent(0.03f32), - top: taffy::style::LengthPercentage::Percent(0.03f32), - bottom: taffy::style::LengthPercentage::Percent(0.03f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(3f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(3f32), - bottom: taffy::style::LengthPercentage::Length(3f32), - }, - ..Default::default() + }, + &[node00], + ); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![fr(1f32), fr(4f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node00], - ) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![fr(1f32), fr(4f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 190f32, "width of node {:?}. Expected {}. Actual {}", node0, 190f32, size.width); assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node0, 41f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 92f32, "width of node {:?}. Expected {}. Actual {}", node00, 92f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node00, 25f32, size.height); assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node00, 8f32, location.x); assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node00, 8f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node000, 36f32, size.width); assert_eq!(size.height, 6f32, "height of node {:?}. Expected {}. Actual {}", node000, 6f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node000, 10f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node000, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); assert_eq!(size.height, 149f32, "height of node {:?}. Expected {}. Actual {}", node1, 149f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/grid_percent_items_width_and_margin.rs b/tests/generated/grid_percent_items_width_and_margin.rs index e092f8325..14e663587 100644 --- a/tests/generated/grid_percent_items_width_and_margin.rs +++ b/tests/generated/grid_percent_items_width_and_margin.rs @@ -3,15 +3,26 @@ fn grid_percent_items_width_and_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: taffy::style::LengthPercentageAuto::Percent(0.05f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(3f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(3f32), + bottom: taffy::style::LengthPercentage::Length(3f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Length(3f32), right: taffy::style::LengthPercentage::Length(3f32), @@ -19,34 +30,19 @@ fn grid_percent_items_width_and_margin() { bottom: taffy::style::LengthPercentage::Length(3f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(3f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(3f32), - bottom: taffy::style::LengthPercentage::Length(3f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node, 31f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node0, 87f32, size.width); assert_eq!(size.height, 6f32, "height of node {:?}. Expected {}. Actual {}", node0, 6f32, size.height); assert_eq!(location.x, 13f32, "x of node {:?}. Expected {}. Actual {}", node0, 13f32, location.x); diff --git a/tests/generated/grid_percent_items_width_and_padding.rs b/tests/generated/grid_percent_items_width_and_padding.rs index 01304ffc2..8d74b00eb 100644 --- a/tests/generated/grid_percent_items_width_and_padding.rs +++ b/tests/generated/grid_percent_items_width_and_padding.rs @@ -3,38 +3,34 @@ fn grid_percent_items_width_and_padding() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Percent(0.03f32), - right: taffy::style::LengthPercentage::Percent(0.03f32), - top: taffy::style::LengthPercentage::Percent(0.03f32), - bottom: taffy::style::LengthPercentage::Percent(0.03f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Percent(0.03f32), + right: taffy::style::LengthPercentage::Percent(0.03f32), + top: taffy::style::LengthPercentage::Percent(0.03f32), + bottom: taffy::style::LengthPercentage::Percent(0.03f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node, 12f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node0, 12f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/grid_percent_tracks_definite_overflow.rs b/tests/generated/grid_percent_tracks_definite_overflow.rs index 6d2b1ce31..38dae1b8c 100644 --- a/tests/generated/grid_percent_tracks_definite_overflow.rs +++ b/tests/generated/grid_percent_tracks_definite_overflow.rs @@ -3,62 +3,60 @@ fn grid_percent_tracks_definite_overflow() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![percent(0.5f32), percent(0.8f32)], - grid_template_columns: vec![percent(0.4f32), percent(0.4f32), percent(0.4f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![percent(0.5f32), percent(0.8f32)], + grid_template_columns: vec![percent(0.4f32), percent(0.4f32), percent(0.4f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(60f32), }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node0, 48f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node1, 48f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node1, 48f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node2, 48f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); assert_eq!(location.x, 96f32, "x of node {:?}. Expected {}. Actual {}", node2, 96f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node3, 48f32, size.width); assert_eq!(size.height, 48f32, "height of node {:?}. Expected {}. Actual {}", node3, 48f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node4, 48f32, size.width); assert_eq!(size.height, 48f32, "height of node {:?}. Expected {}. Actual {}", node4, 48f32, size.height); assert_eq!(location.x, 48f32, "x of node {:?}. Expected {}. Actual {}", node4, 48f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node4, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 48f32, "width of node {:?}. Expected {}. Actual {}", node5, 48f32, size.width); assert_eq!(size.height, 48f32, "height of node {:?}. Expected {}. Actual {}", node5, 48f32, size.height); assert_eq!(location.x, 96f32, "x of node {:?}. Expected {}. Actual {}", node5, 96f32, location.x); diff --git a/tests/generated/grid_percent_tracks_definite_underflow.rs b/tests/generated/grid_percent_tracks_definite_underflow.rs index 12bd7212e..0ac3012de 100644 --- a/tests/generated/grid_percent_tracks_definite_underflow.rs +++ b/tests/generated/grid_percent_tracks_definite_underflow.rs @@ -3,62 +3,60 @@ fn grid_percent_tracks_definite_underflow() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![percent(0.3f32), percent(0.6f32)], - grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(60f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![percent(0.3f32), percent(0.6f32)], + grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(60f32), }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node0, 12f32, size.width); assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node0, 18f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 24f32, "width of node {:?}. Expected {}. Actual {}", node1, 24f32, size.width); assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node1, 18f32, size.height); assert_eq!(location.x, 12f32, "x of node {:?}. Expected {}. Actual {}", node1, 12f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node2, 36f32, size.width); assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node2, 18f32, size.height); assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node2, 36f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node3, 12f32, size.width); assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node3, 36f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node3, 18f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 24f32, "width of node {:?}. Expected {}. Actual {}", node4, 24f32, size.width); assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node4, 36f32, size.height); assert_eq!(location.x, 12f32, "x of node {:?}. Expected {}. Actual {}", node4, 12f32, location.x); assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node4, 18f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node5, 36f32, size.width); assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node5, 36f32, size.height); assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node5, 36f32, location.x); diff --git a/tests/generated/grid_percent_tracks_indefinite_only.rs b/tests/generated/grid_percent_tracks_indefinite_only.rs index 27114c4ba..3449d04d4 100644 --- a/tests/generated/grid_percent_tracks_indefinite_only.rs +++ b/tests/generated/grid_percent_tracks_indefinite_only.rs @@ -3,58 +3,56 @@ fn grid_percent_tracks_indefinite_only() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![percent(0.3f32), percent(0.6f32)], - grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![percent(0.3f32), percent(0.6f32)], + grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node5, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); diff --git a/tests/generated/grid_percent_tracks_indefinite_with_content_overflow.rs b/tests/generated/grid_percent_tracks_indefinite_with_content_overflow.rs index a29b97a67..1479b7963 100644 --- a/tests/generated/grid_percent_tracks_indefinite_with_content_overflow.rs +++ b/tests/generated/grid_percent_tracks_indefinite_with_content_overflow.rs @@ -3,80 +3,74 @@ fn grid_percent_tracks_indefinite_with_content_overflow() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![percent(0.5f32), percent(0.8f32)], + grid_template_columns: vec![percent(0.4f32), percent(0.4f32), percent(0.4f32)], ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![percent(0.5f32), percent(0.8f32)], - grid_template_columns: vec![percent(0.4f32), percent(0.4f32), percent(0.4f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node2, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node3, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node4, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node5, 80f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node5, 40f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node6, 80f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node6, 80f32, location.x); diff --git a/tests/generated/grid_percent_tracks_indefinite_with_content_underflow.rs b/tests/generated/grid_percent_tracks_indefinite_with_content_underflow.rs index 646fb7e5b..7897a558e 100644 --- a/tests/generated/grid_percent_tracks_indefinite_with_content_underflow.rs +++ b/tests/generated/grid_percent_tracks_indefinite_with_content_underflow.rs @@ -3,80 +3,74 @@ fn grid_percent_tracks_indefinite_with_content_underflow() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![percent(0.3f32), percent(0.6f32)], + grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)], ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![percent(0.3f32), percent(0.6f32)], - grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4, node5, node6], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node2, 10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node4, 10f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node4, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node4, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node5, 60f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node5, 10f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node5, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node6, 30f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node6, 60f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node6, 30f32, location.x); diff --git a/tests/generated/grid_placement_auto_negative.rs b/tests/generated/grid_placement_auto_negative.rs index c734172a4..1f5916448 100644 --- a/tests/generated/grid_placement_auto_negative.rs +++ b/tests/generated/grid_placement_auto_negative.rs @@ -3,55 +3,49 @@ fn grid_placement_auto_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(-5i16), end: taffy::style::GridPlacement::Auto }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(-5i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.rs b/tests/generated/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.rs index 7ab2cd096..70ed7c7b4 100644 --- a/tests/generated/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.rs +++ b/tests/generated/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.rs @@ -3,60 +3,52 @@ fn grid_placement_definite_in_secondary_axis_with_fully_definite_negative() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(-4i16), end: taffy::style::GridPlacement::Auto }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(-4i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_relative_all_sides.rs b/tests/generated/grid_relative_all_sides.rs index e980f92db..0624c8e3f 100644 --- a/tests/generated/grid_relative_all_sides.rs +++ b/tests/generated/grid_relative_all_sides.rs @@ -3,41 +3,37 @@ fn grid_relative_all_sides() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(40f32), height: auto() }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/grid_relayout_vertical_text.rs b/tests/generated/grid_relayout_vertical_text.rs index 8f59b4a54..6fcea98ff 100644 --- a/tests/generated/grid_relayout_vertical_text.rs +++ b/tests/generated/grid_relayout_vertical_text.rs @@ -3,62 +3,44 @@ fn grid_relayout_vertical_text() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Vertical, - None, - ) - }), - ) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![min_content()], - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Vertical, None) + }), + ); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![min_content()], + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/grid_repeat_integer.rs b/tests/generated/grid_repeat_integer.rs index 5f8341875..20eb35c08 100644 --- a/tests/generated/grid_repeat_integer.rs +++ b/tests/generated/grid_repeat_integer.rs @@ -3,80 +3,78 @@ fn grid_repeat_integer() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![repeat(GridTrackRepetition::Count(3u16), vec![length(40f32)])], - grid_template_columns: vec![repeat(GridTrackRepetition::Count(3u16), vec![length(40f32)])], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![repeat(GridTrackRepetition::Count(3u16), vec![length(40f32)])], + grid_template_columns: vec![repeat(GridTrackRepetition::Count(3u16), vec![length(40f32)])], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_repeat_mixed.rs b/tests/generated/grid_repeat_mixed.rs index 38da44ce6..d2671bfb5 100644 --- a/tests/generated/grid_repeat_mixed.rs +++ b/tests/generated/grid_repeat_mixed.rs @@ -3,88 +3,86 @@ fn grid_repeat_mixed() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![ - length(40f32), - repeat(GridTrackRepetition::Count(1u16), vec![length(40f32)]), - repeat(GridTrackRepetition::AutoFill, vec![length(40f32)]), - ], - grid_template_columns: vec![ - length(40f32), - repeat(GridTrackRepetition::Count(1u16), vec![length(40f32)]), - repeat(GridTrackRepetition::AutoFill, vec![length(40f32)]), - ], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![ + length(40f32), + repeat(GridTrackRepetition::Count(1u16), vec![length(40f32)]), + repeat(GridTrackRepetition::AutoFill, vec![length(40f32)]), + ], + grid_template_columns: vec![ + length(40f32), + repeat(GridTrackRepetition::Count(1u16), vec![length(40f32)]), + repeat(GridTrackRepetition::AutoFill, vec![length(40f32)]), + ], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x); diff --git a/tests/generated/grid_size_child_fixed_tracks.rs b/tests/generated/grid_size_child_fixed_tracks.rs index c719a2c96..c563c533d 100644 --- a/tests/generated/grid_size_child_fixed_tracks.rs +++ b/tests/generated/grid_size_child_fixed_tracks.rs @@ -3,148 +3,106 @@ fn grid_size_child_fixed_tracks() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Start), - justify_self: Some(taffy::style::JustifySelf::Start), - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHH\u{200b}HHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node3 = taffy.new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node4 = taffy.new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(30f32), height: auto() }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], + grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(120f32), + height: taffy::style::Dimension::Length(120f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Start), - justify_self: Some(taffy::style::JustifySelf::Start), - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHH\u{200b}HHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Start), - justify_self: Some(taffy::style::JustifySelf::Start), - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node3 = taffy - .new_leaf_with_measure( - taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Start), - justify_self: Some(taffy::style::JustifySelf::Start), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node4 = taffy - .new_leaf_with_measure( - taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Start), - justify_self: Some(taffy::style::JustifySelf::Start), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(30f32), height: auto() }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32), length(40f32)], - grid_template_columns: vec![length(40f32), length(40f32), length(40f32)], - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(120f32), - height: taffy::style::Dimension::Length(120f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x); diff --git a/tests/generated/grid_span_13_most_non_flex_with_minmax_indefinite.rs b/tests/generated/grid_span_13_most_non_flex_with_minmax_indefinite.rs index 22c75dc33..f9c76dc07 100644 --- a/tests/generated/grid_span_13_most_non_flex_with_minmax_indefinite.rs +++ b/tests/generated/grid_span_13_most_non_flex_with_minmax_indefinite.rs @@ -3,137 +3,127 @@ fn grid_span_13_most_non_flex_with_minmax_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(13u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node10 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node11 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node12 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node13 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32)], - grid_template_columns: vec![ - min_content(), - max_content(), - fit_content(length(20f32)), - auto(), - length(10f32), - percent(0.2f32), - minmax(length(2f32), auto()), - minmax(length(2f32), length(4f32)), - minmax(length(2f32), min_content()), - minmax(length(2f32), max_content()), - minmax(min_content(), max_content()), - minmax(min_content(), auto()), - minmax(max_content(), auto()), - ], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(13u16) }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node10 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node11 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node12 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node13 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32)], + grid_template_columns: vec![ + min_content(), + max_content(), + fit_content(length(20f32)), + auto(), + length(10f32), + percent(0.2f32), + minmax(length(2f32), auto()), + minmax(length(2f32), length(4f32)), + minmax(length(2f32), min_content()), + minmax(length(2f32), max_content()), + minmax(min_content(), max_content()), + minmax(min_content(), auto()), + minmax(max_content(), auto()), + ], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 322f32, "width of node {:?}. Expected {}. Actual {}", node, 322f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 322f32, "width of node {:?}. Expected {}. Actual {}", node0, 322f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node1, 11f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 91f32, "width of node {:?}. Expected {}. Actual {}", node2, 91f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 11f32, "x of node {:?}. Expected {}. Actual {}", node2, 11f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node3, 11f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 102f32, "x of node {:?}. Expected {}. Actual {}", node3, 102f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node4, 11f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 113f32, "x of node {:?}. Expected {}. Actual {}", node4, 113f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 124f32, "x of node {:?}. Expected {}. Actual {}", node5, 124f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 65f32, "width of node {:?}. Expected {}. Actual {}", node6, 65f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 134f32, "x of node {:?}. Expected {}. Actual {}", node6, 134f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node7, 2f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 199f32, "x of node {:?}. Expected {}. Actual {}", node7, 199f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 4f32, "width of node {:?}. Expected {}. Actual {}", node8, 4f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 201f32, "x of node {:?}. Expected {}. Actual {}", node8, 201f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node9).unwrap(); + let Layout { size, location, .. } = taffy.layout(node9); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node9, 2f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node9, 40f32, size.height); assert_eq!(location.x, 205f32, "x of node {:?}. Expected {}. Actual {}", node9, 205f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node9, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node10, 2f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node10, 40f32, size.height); assert_eq!(location.x, 207f32, "x of node {:?}. Expected {}. Actual {}", node10, 207f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node10, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node11, 11f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node11, 40f32, size.height); assert_eq!(location.x, 209f32, "x of node {:?}. Expected {}. Actual {}", node11, 209f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node11, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node12).unwrap(); + let Layout { size, location, .. } = taffy.layout(node12); assert_eq!(size.width, 11f32, "width of node {:?}. Expected {}. Actual {}", node12, 11f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node12, 40f32, size.height); assert_eq!(location.x, 220f32, "x of node {:?}. Expected {}. Actual {}", node12, 220f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node12, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node13).unwrap(); + let Layout { size, location, .. } = taffy.layout(node13); assert_eq!(size.width, 91f32, "width of node {:?}. Expected {}. Actual {}", node13, 91f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node13, 40f32, size.height); assert_eq!(location.x, 231f32, "x of node {:?}. Expected {}. Actual {}", node13, 231f32, location.x); diff --git a/tests/generated/grid_span_13_most_non_flex_with_minmax_indefinite_hidden.rs b/tests/generated/grid_span_13_most_non_flex_with_minmax_indefinite_hidden.rs index a41245e1f..67e07e836 100644 --- a/tests/generated/grid_span_13_most_non_flex_with_minmax_indefinite_hidden.rs +++ b/tests/generated/grid_span_13_most_non_flex_with_minmax_indefinite_hidden.rs @@ -3,142 +3,129 @@ fn grid_span_13_most_non_flex_with_minmax_indefinite_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(13u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node10 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node11 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node12 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node13 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32)], - grid_template_columns: vec![ - min_content(), - max_content(), - fit_content(length(20f32)), - auto(), - length(10f32), - percent(0.2f32), - minmax(length(2f32), auto()), - minmax(length(2f32), length(4f32)), - minmax(length(2f32), min_content()), - minmax(length(2f32), max_content()), - minmax(min_content(), max_content()), - minmax(min_content(), auto()), - minmax(max_content(), auto()), - ], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(13u16) }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node10 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node11 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node12 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node13 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32)], + grid_template_columns: vec![ + min_content(), + max_content(), + fit_content(length(20f32)), + auto(), + length(10f32), + percent(0.2f32), + minmax(length(2f32), auto()), + minmax(length(2f32), length(4f32)), + minmax(length(2f32), min_content()), + minmax(length(2f32), max_content()), + minmax(min_content(), max_content()), + minmax(min_content(), auto()), + minmax(max_content(), auto()), + ], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 322f32, "width of node {:?}. Expected {}. Actual {}", node, 322f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 322f32, "width of node {:?}. Expected {}. Actual {}", node0, 322f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 16f32, "width of node {:?}. Expected {}. Actual {}", node1, 16f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 95f32, "width of node {:?}. Expected {}. Actual {}", node2, 95f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 16f32, "x of node {:?}. Expected {}. Actual {}", node2, 16f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 111f32, "x of node {:?}. Expected {}. Actual {}", node3, 111f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 111f32, "x of node {:?}. Expected {}. Actual {}", node4, 111f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 111f32, "x of node {:?}. Expected {}. Actual {}", node5, 111f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 64f32, "width of node {:?}. Expected {}. Actual {}", node6, 64f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 121f32, "x of node {:?}. Expected {}. Actual {}", node6, 121f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node7, 2f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 185f32, "x of node {:?}. Expected {}. Actual {}", node7, 185f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 4f32, "width of node {:?}. Expected {}. Actual {}", node8, 4f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 187f32, "x of node {:?}. Expected {}. Actual {}", node8, 187f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node8, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node9).unwrap(); + let Layout { size, location, .. } = taffy.layout(node9); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node9, 2f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node9, 40f32, size.height); assert_eq!(location.x, 191f32, "x of node {:?}. Expected {}. Actual {}", node9, 191f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node9, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node10, 2f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node10, 40f32, size.height); assert_eq!(location.x, 193f32, "x of node {:?}. Expected {}. Actual {}", node10, 193f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node10, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 16f32, "width of node {:?}. Expected {}. Actual {}", node11, 16f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node11, 40f32, size.height); assert_eq!(location.x, 195f32, "x of node {:?}. Expected {}. Actual {}", node11, 195f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node11, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node12).unwrap(); + let Layout { size, location, .. } = taffy.layout(node12); assert_eq!(size.width, 15f32, "width of node {:?}. Expected {}. Actual {}", node12, 15f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node12, 40f32, size.height); assert_eq!(location.x, 211f32, "x of node {:?}. Expected {}. Actual {}", node12, 211f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node12, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node13).unwrap(); + let Layout { size, location, .. } = taffy.layout(node13); assert_eq!(size.width, 96f32, "width of node {:?}. Expected {}. Actual {}", node13, 96f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node13, 40f32, size.height); assert_eq!(location.x, 226f32, "x of node {:?}. Expected {}. Actual {}", node13, 226f32, location.x); diff --git a/tests/generated/grid_span_2_max_content_auto_indefinite.rs b/tests/generated/grid_span_2_max_content_auto_indefinite.rs index 6b1b33df9..17ad3167b 100644 --- a/tests/generated/grid_span_2_max_content_auto_indefinite.rs +++ b/tests/generated/grid_span_2_max_content_auto_indefinite.rs @@ -3,70 +3,56 @@ fn grid_span_2_max_content_auto_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![max_content(), auto()], ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![max_content(), auto()], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_max_content_auto_indefinite_hidden.rs b/tests/generated/grid_span_2_max_content_auto_indefinite_hidden.rs index 069c4f44e..9e6880aab 100644 --- a/tests/generated/grid_span_2_max_content_auto_indefinite_hidden.rs +++ b/tests/generated/grid_span_2_max_content_auto_indefinite_hidden.rs @@ -3,46 +3,40 @@ fn grid_span_2_max_content_auto_indefinite_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![max_content(), auto()], ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![max_content(), auto()], - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/grid_span_2_max_content_fit_content_10px_indefinite.rs b/tests/generated/grid_span_2_max_content_fit_content_10px_indefinite.rs index 2affac2db..7cb60dca2 100644 --- a/tests/generated/grid_span_2_max_content_fit_content_10px_indefinite.rs +++ b/tests/generated/grid_span_2_max_content_fit_content_10px_indefinite.rs @@ -3,70 +3,56 @@ fn grid_span_2_max_content_fit_content_10px_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![max_content(), fit_content(length(10f32))], ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![max_content(), fit_content(length(10f32))], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_max_content_fit_content_10px_indefinite_hidden.rs b/tests/generated/grid_span_2_max_content_fit_content_10px_indefinite_hidden.rs index ba499d1cd..241344814 100644 --- a/tests/generated/grid_span_2_max_content_fit_content_10px_indefinite_hidden.rs +++ b/tests/generated/grid_span_2_max_content_fit_content_10px_indefinite_hidden.rs @@ -3,75 +3,58 @@ fn grid_span_2_max_content_fit_content_10px_indefinite_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![max_content(), fit_content(length(10f32))], ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![max_content(), fit_content(length(10f32))], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_max_content_fit_content_80px_indefinite.rs b/tests/generated/grid_span_2_max_content_fit_content_80px_indefinite.rs index 29b8dbfc8..a25d0df68 100644 --- a/tests/generated/grid_span_2_max_content_fit_content_80px_indefinite.rs +++ b/tests/generated/grid_span_2_max_content_fit_content_80px_indefinite.rs @@ -3,70 +3,56 @@ fn grid_span_2_max_content_fit_content_80px_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![max_content(), fit_content(length(80f32))], ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![max_content(), fit_content(length(80f32))], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_max_content_fit_content_80px_indefinite_hidden.rs b/tests/generated/grid_span_2_max_content_fit_content_80px_indefinite_hidden.rs index 207de9796..8fdff6a4c 100644 --- a/tests/generated/grid_span_2_max_content_fit_content_80px_indefinite_hidden.rs +++ b/tests/generated/grid_span_2_max_content_fit_content_80px_indefinite_hidden.rs @@ -3,75 +3,58 @@ fn grid_span_2_max_content_fit_content_80px_indefinite_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![max_content(), fit_content(length(80f32))], ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![max_content(), fit_content(length(80f32))], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_max_content_max_content_indefinite.rs b/tests/generated/grid_span_2_max_content_max_content_indefinite.rs index 3dca84357..2f32a6f6f 100644 --- a/tests/generated/grid_span_2_max_content_max_content_indefinite.rs +++ b/tests/generated/grid_span_2_max_content_max_content_indefinite.rs @@ -3,70 +3,56 @@ fn grid_span_2_max_content_max_content_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![max_content(), max_content()], ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![max_content(), max_content()], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_min_content_auto_indefinite.rs b/tests/generated/grid_span_2_min_content_auto_indefinite.rs index df0cfba8a..77597a0be 100644 --- a/tests/generated/grid_span_2_min_content_auto_indefinite.rs +++ b/tests/generated/grid_span_2_min_content_auto_indefinite.rs @@ -3,57 +3,47 @@ fn grid_span_2_min_content_auto_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![min_content(), auto()], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![min_content(), auto()], + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_min_content_auto_indefinite_hidden.rs b/tests/generated/grid_span_2_min_content_auto_indefinite_hidden.rs index 2c116613b..eeebc1750 100644 --- a/tests/generated/grid_span_2_min_content_auto_indefinite_hidden.rs +++ b/tests/generated/grid_span_2_min_content_auto_indefinite_hidden.rs @@ -3,62 +3,49 @@ fn grid_span_2_min_content_auto_indefinite_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![min_content(), auto()], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![min_content(), auto()], + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_min_content_fit_content_10px_indefinite.rs b/tests/generated/grid_span_2_min_content_fit_content_10px_indefinite.rs index 9f873c1b6..f6233e4e2 100644 --- a/tests/generated/grid_span_2_min_content_fit_content_10px_indefinite.rs +++ b/tests/generated/grid_span_2_min_content_fit_content_10px_indefinite.rs @@ -3,70 +3,56 @@ fn grid_span_2_min_content_fit_content_10px_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![min_content(), fit_content(length(10f32))], ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![min_content(), fit_content(length(10f32))], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_min_content_fit_content_10px_indefinite_hidden.rs b/tests/generated/grid_span_2_min_content_fit_content_10px_indefinite_hidden.rs index 916156ee5..d5b65714b 100644 --- a/tests/generated/grid_span_2_min_content_fit_content_10px_indefinite_hidden.rs +++ b/tests/generated/grid_span_2_min_content_fit_content_10px_indefinite_hidden.rs @@ -3,75 +3,58 @@ fn grid_span_2_min_content_fit_content_10px_indefinite_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![min_content(), fit_content(length(10f32))], ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![min_content(), fit_content(length(10f32))], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_min_content_fit_content_30px_indefinite.rs b/tests/generated/grid_span_2_min_content_fit_content_30px_indefinite.rs index c7c38f130..22e4f117d 100644 --- a/tests/generated/grid_span_2_min_content_fit_content_30px_indefinite.rs +++ b/tests/generated/grid_span_2_min_content_fit_content_30px_indefinite.rs @@ -3,70 +3,56 @@ fn grid_span_2_min_content_fit_content_30px_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![min_content(), fit_content(length(30f32))], ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![min_content(), fit_content(length(30f32))], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_min_content_fit_content_30px_indefinite_hidden.rs b/tests/generated/grid_span_2_min_content_fit_content_30px_indefinite_hidden.rs index 63b87b105..3a940221d 100644 --- a/tests/generated/grid_span_2_min_content_fit_content_30px_indefinite_hidden.rs +++ b/tests/generated/grid_span_2_min_content_fit_content_30px_indefinite_hidden.rs @@ -3,75 +3,58 @@ fn grid_span_2_min_content_fit_content_30px_indefinite_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![min_content(), fit_content(length(30f32))], ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![min_content(), fit_content(length(30f32))], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node, 70f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node2, 70f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_min_content_fit_content_80px_indefinite.rs b/tests/generated/grid_span_2_min_content_fit_content_80px_indefinite.rs index a85aaaec3..bf89f5cda 100644 --- a/tests/generated/grid_span_2_min_content_fit_content_80px_indefinite.rs +++ b/tests/generated/grid_span_2_min_content_fit_content_80px_indefinite.rs @@ -3,70 +3,56 @@ fn grid_span_2_min_content_fit_content_80px_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![min_content(), fit_content(length(80f32))], ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![min_content(), fit_content(length(80f32))], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_min_content_fit_content_80px_indefinite_hidden.rs b/tests/generated/grid_span_2_min_content_fit_content_80px_indefinite_hidden.rs index ecc9ef474..f01065f31 100644 --- a/tests/generated/grid_span_2_min_content_fit_content_80px_indefinite_hidden.rs +++ b/tests/generated/grid_span_2_min_content_fit_content_80px_indefinite_hidden.rs @@ -3,75 +3,58 @@ fn grid_span_2_min_content_fit_content_80px_indefinite_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![min_content(), fit_content(length(80f32))], ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![min_content(), fit_content(length(80f32))], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_min_content_max_content_indefinite.rs b/tests/generated/grid_span_2_min_content_max_content_indefinite.rs index 2db3a2a20..8fbc2e007 100644 --- a/tests/generated/grid_span_2_min_content_max_content_indefinite.rs +++ b/tests/generated/grid_span_2_min_content_max_content_indefinite.rs @@ -3,70 +3,56 @@ fn grid_span_2_min_content_max_content_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![min_content(), max_content()], ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![min_content(), max_content()], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_2_min_content_min_content_indefinite.rs b/tests/generated/grid_span_2_min_content_min_content_indefinite.rs index e96929685..64843dd0d 100644 --- a/tests/generated/grid_span_2_min_content_min_content_indefinite.rs +++ b/tests/generated/grid_span_2_min_content_min_content_indefinite.rs @@ -3,70 +3,56 @@ fn grid_span_2_min_content_min_content_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + ..Default::default() + }); + let node2 = taffy.new_leaf_with_measure( + taffy::style::Style { grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto }, + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32)], + grid_template_columns: vec![min_content(), min_content()], ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto }, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH\u{200b}HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32)], - grid_template_columns: vec![min_content(), min_content()], - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/grid_span_6_all_non_flex_indefinite.rs b/tests/generated/grid_span_6_all_non_flex_indefinite.rs index 2949ebffb..dcce94a4f 100644 --- a/tests/generated/grid_span_6_all_non_flex_indefinite.rs +++ b/tests/generated/grid_span_6_all_non_flex_indefinite.rs @@ -3,88 +3,78 @@ fn grid_span_6_all_non_flex_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(6u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHH\u{200b}HHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32)], - grid_template_columns: vec![ - min_content(), - max_content(), - fit_content(length(20f32)), - auto(), - length(10f32), - percent(0.2f32), - ], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(6u16) }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHH\u{200b}HHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32)], + grid_template_columns: vec![ + min_content(), + max_content(), + fit_content(length(20f32)), + auto(), + length(10f32), + percent(0.2f32), + ], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node, 160f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 89f32, "width of node {:?}. Expected {}. Actual {}", node2, 89f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node2, 10f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node3, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 99f32, "x of node {:?}. Expected {}. Actual {}", node3, 99f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node4, 9f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 109f32, "x of node {:?}. Expected {}. Actual {}", node4, 109f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 118f32, "x of node {:?}. Expected {}. Actual {}", node5, 118f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node6, 32f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node6, 128f32, location.x); diff --git a/tests/generated/grid_span_6_all_non_flex_indefinite_hidden.rs b/tests/generated/grid_span_6_all_non_flex_indefinite_hidden.rs index df35a351c..e0c4e34be 100644 --- a/tests/generated/grid_span_6_all_non_flex_indefinite_hidden.rs +++ b/tests/generated/grid_span_6_all_non_flex_indefinite_hidden.rs @@ -3,93 +3,80 @@ fn grid_span_6_all_non_flex_indefinite_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(6u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHH\u{200b}HHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32)], - grid_template_columns: vec![ - min_content(), - max_content(), - fit_content(length(20f32)), - auto(), - length(10f32), - percent(0.2f32), - ], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(6u16) }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHH\u{200b}HHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32)], + grid_template_columns: vec![ + min_content(), + max_content(), + fit_content(length(20f32)), + auto(), + length(10f32), + percent(0.2f32), + ], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node, 160f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 19f32, "width of node {:?}. Expected {}. Actual {}", node1, 19f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 99f32, "width of node {:?}. Expected {}. Actual {}", node2, 99f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 19f32, "x of node {:?}. Expected {}. Actual {}", node2, 19f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 118f32, "x of node {:?}. Expected {}. Actual {}", node3, 118f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 118f32, "x of node {:?}. Expected {}. Actual {}", node4, 118f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 118f32, "x of node {:?}. Expected {}. Actual {}", node5, 118f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node6, 32f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 128f32, "x of node {:?}. Expected {}. Actual {}", node6, 128f32, location.x); diff --git a/tests/generated/grid_span_8_all_track_types_indefinite.rs b/tests/generated/grid_span_8_all_track_types_indefinite.rs index 09f93a707..39d666a2c 100644 --- a/tests/generated/grid_span_8_all_track_types_indefinite.rs +++ b/tests/generated/grid_span_8_all_track_types_indefinite.rs @@ -3,102 +3,92 @@ fn grid_span_8_all_track_types_indefinite() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(8u16) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHH\u{200b}HHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(40f32), length(40f32)], - grid_template_columns: vec![ - min_content(), - max_content(), - fit_content(length(20f32)), - auto(), - length(10f32), - percent(0.2f32), - fr(1f32), - fr(2f32), - ], - ..Default::default() - }, - &[node0, node1, node2, node3, node4, node5, node6, node7, node8], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(8u16) }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHH\u{200b}HHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(40f32), length(40f32)], + grid_template_columns: vec![ + min_content(), + max_content(), + fit_content(length(20f32)), + auto(), + length(10f32), + percent(0.2f32), + fr(1f32), + fr(2f32), + ], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node, 160f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node5).unwrap(); + let Layout { size, location, .. } = taffy.layout(node5); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node6).unwrap(); + let Layout { size, location, .. } = taffy.layout(node6); assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node6, 32f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node6, 10f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node7).unwrap(); + let Layout { size, location, .. } = taffy.layout(node7); assert_eq!(size.width, 39f32, "width of node {:?}. Expected {}. Actual {}", node7, 39f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height); assert_eq!(location.x, 42f32, "x of node {:?}. Expected {}. Actual {}", node7, 42f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node7, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node8).unwrap(); + let Layout { size, location, .. } = taffy.layout(node8); assert_eq!(size.width, 79f32, "width of node {:?}. Expected {}. Actual {}", node8, 79f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height); assert_eq!(location.x, 81f32, "x of node {:?}. Expected {}. Actual {}", node8, 81f32, location.x); diff --git a/tests/generated/gridflex_column_integration.rs b/tests/generated/gridflex_column_integration.rs index 4ac54cec9..46354ecfe 100644 --- a/tests/generated/gridflex_column_integration.rs +++ b/tests/generated/gridflex_column_integration.rs @@ -3,113 +3,77 @@ fn gridflex_column_integration() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node01 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node02 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node03 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![fr(1f32), fr(1f32)], - grid_template_columns: vec![fr(1f32), fr(1f32)], - ..Default::default() - }, - &[node00, node01, node02, node03], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node00 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node01 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node02 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node03 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![fr(1f32), fr(1f32)], + grid_template_columns: vec![fr(1f32), fr(1f32)], + ..Default::default() + }, + &[node00, node01, node02, node03], + ); + let node = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node02).unwrap(); + let Layout { size, location, .. } = taffy.layout(node02); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node02, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node02, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node03).unwrap(); + let Layout { size, location, .. } = taffy.layout(node03); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node03, 10f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); diff --git a/tests/generated/gridflex_kitchen_sink.rs b/tests/generated/gridflex_kitchen_sink.rs index 4abcc185d..87a6b4bc3 100644 --- a/tests/generated/gridflex_kitchen_sink.rs +++ b/tests/generated/gridflex_kitchen_sink.rs @@ -3,165 +3,131 @@ fn gridflex_kitchen_sink() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node00100 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + ..Default::default() + }); + let node00101 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node00102 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node00103 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node0010 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![percent(0.3f32), percent(0.1f32)], + grid_template_columns: vec![auto(), percent(0.1f32)], ..Default::default() - }) - .unwrap(); - let node00100 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() }, + }, + &[node00100, node00101, node00102, node00103], + ); + let node001 = taffy.new_with_children( + taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node00101 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node00102 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node00103 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node0010 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![percent(0.3f32), percent(0.1f32)], - grid_template_columns: vec![auto(), percent(0.1f32)], - ..Default::default() - }, - &[node00100, node00101, node00102, node00103], - ) - .unwrap(); - let node001 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0010], - ) - .unwrap(); - let node00 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node000, node001]).unwrap(); - let node01 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node02 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node03 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![fr(1f32), fr(1f32)], - grid_template_columns: vec![fr(1f32), fr(1f32)], - ..Default::default() - }, - &[node00, node01, node02, node03], - ) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0010], + ); + let node00 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node000, node001]); + let node01 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node02 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node03 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![fr(1f32), fr(1f32)], + grid_template_columns: vec![fr(1f32), fr(1f32)], + ..Default::default() + }, + &[node00, node01, node02, node03], + ); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node, 140f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 140f32, "width of node {:?}. Expected {}. Actual {}", node0, 140f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node000, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node001).unwrap(); + let Layout { size, location, .. } = taffy.layout(node001); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node001, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node001, 10f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node001, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node001, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0010).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0010); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0010, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0010, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0010, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0010, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00100).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00100); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00100, 20f32, size.width); assert_eq!(size.height, 3f32, "height of node {:?}. Expected {}. Actual {}", node00100, 3f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00101).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00101); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node00101, 2f32, size.width); assert_eq!(size.height, 3f32, "height of node {:?}. Expected {}. Actual {}", node00101, 3f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00101, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00101, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00102).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00102); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00102, 20f32, size.width); assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node00102, 1f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00102, 0f32, location.x); assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node00102, 3f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00103).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00103); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node00103, 2f32, size.width); assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node00103, 1f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00103, 20f32, location.x); assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node00103, 3f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node01, 70f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node01, 70f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node02).unwrap(); + let Layout { size, location, .. } = taffy.layout(node02); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node02, 70f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node02, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node02, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node03).unwrap(); + let Layout { size, location, .. } = taffy.layout(node03); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node03, 70f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node03, 10f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node03, 70f32, location.x); diff --git a/tests/generated/gridflex_kitchen_sink_minimise.rs b/tests/generated/gridflex_kitchen_sink_minimise.rs index 8ab89ee32..0a0437ffe 100644 --- a/tests/generated/gridflex_kitchen_sink_minimise.rs +++ b/tests/generated/gridflex_kitchen_sink_minimise.rs @@ -3,45 +3,41 @@ fn gridflex_kitchen_sink_minimise() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![length(20f32)], + grid_template_columns: vec![fr(1f32), fr(1f32)], ..Default::default() - }) - .unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![length(20f32)], - grid_template_columns: vec![fr(1f32), fr(1f32)], - ..Default::default() - }, - &[node00, node01], - ) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00, node01], + ); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node01, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x); diff --git a/tests/generated/gridflex_kitchen_sink_minimise2.rs b/tests/generated/gridflex_kitchen_sink_minimise2.rs index 81825ef61..3677d3136 100644 --- a/tests/generated/gridflex_kitchen_sink_minimise2.rs +++ b/tests/generated/gridflex_kitchen_sink_minimise2.rs @@ -3,51 +3,45 @@ fn gridflex_kitchen_sink_minimise2() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![auto()], + grid_template_columns: vec![auto()], ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![auto()], - grid_template_columns: vec![auto()], - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/gridflex_kitchen_sink_minimise3.rs b/tests/generated/gridflex_kitchen_sink_minimise3.rs index b6bd5ab37..c9cca18fa 100644 --- a/tests/generated/gridflex_kitchen_sink_minimise3.rs +++ b/tests/generated/gridflex_kitchen_sink_minimise3.rs @@ -3,68 +3,62 @@ fn gridflex_kitchen_sink_minimise3() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![percent(0.3f32), percent(0.1f32)], + grid_template_columns: vec![auto(), percent(0.1f32)], ..Default::default() - }) - .unwrap(); - let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![percent(0.3f32), percent(0.1f32)], - grid_template_columns: vec![auto(), percent(0.1f32)], - ..Default::default() - }, - &[node00, node01, node02, node03], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00, node01, node02, node03], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node01, 2f32, size.width); assert_eq!(size.height, 6f32, "height of node {:?}. Expected {}. Actual {}", node01, 6f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node02).unwrap(); + let Layout { size, location, .. } = taffy.layout(node02); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); assert_eq!(size.height, 2f32, "height of node {:?}. Expected {}. Actual {}", node02, 2f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); assert_eq!(location.y, 6f32, "y of node {:?}. Expected {}. Actual {}", node02, 6f32, location.y); - let Layout { size, location, .. } = taffy.layout(node03).unwrap(); + let Layout { size, location, .. } = taffy.layout(node03); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node03, 2f32, size.width); assert_eq!(size.height, 2f32, "height of node {:?}. Expected {}. Actual {}", node03, 2f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); diff --git a/tests/generated/gridflex_row_integration.rs b/tests/generated/gridflex_row_integration.rs index 2d0b412f1..f5c90a2b5 100644 --- a/tests/generated/gridflex_row_integration.rs +++ b/tests/generated/gridflex_row_integration.rs @@ -3,108 +3,74 @@ fn gridflex_row_integration() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node01 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node02 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node03 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Grid, - grid_template_rows: vec![fr(1f32), fr(1f32)], - grid_template_columns: vec![fr(1f32), fr(1f32)], - ..Default::default() - }, - &[node00, node01, node02, node03], - ) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node00 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node01 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node02 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node03 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![fr(1f32), fr(1f32)], + grid_template_columns: vec![fr(1f32), fr(1f32)], + ..Default::default() + }, + &[node00, node01, node02, node03], + ); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node02).unwrap(); + let Layout { size, location, .. } = taffy.layout(node02); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node02, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node02, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node02, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node03).unwrap(); + let Layout { size, location, .. } = taffy.layout(node03); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node03, 10f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x); diff --git a/tests/generated/intrinsic_sizing_cross_size_column.rs b/tests/generated/intrinsic_sizing_cross_size_column.rs index 20d212bb6..87a4a5de8 100644 --- a/tests/generated/intrinsic_sizing_cross_size_column.rs +++ b/tests/generated/intrinsic_sizing_cross_size_column.rs @@ -3,26 +3,18 @@ fn intrinsic_sizing_cross_size_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf_with_measure( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf_with_measure( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/intrinsic_sizing_main_size_column.rs b/tests/generated/intrinsic_sizing_main_size_column.rs index addd589e6..3fa0d638e 100644 --- a/tests/generated/intrinsic_sizing_main_size_column.rs +++ b/tests/generated/intrinsic_sizing_main_size_column.rs @@ -3,26 +3,18 @@ fn intrinsic_sizing_main_size_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf_with_measure( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Vertical, - None, - ) - }), - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf_with_measure( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Vertical, None) + }), + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/intrinsic_sizing_main_size_column_nested.rs b/tests/generated/intrinsic_sizing_main_size_column_nested.rs index 15204c828..9acf0855d 100644 --- a/tests/generated/intrinsic_sizing_main_size_column_nested.rs +++ b/tests/generated/intrinsic_sizing_main_size_column_nested.rs @@ -3,37 +3,27 @@ fn intrinsic_sizing_main_size_column_nested() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Vertical, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Vertical, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/intrinsic_sizing_main_size_column_wrap.rs b/tests/generated/intrinsic_sizing_main_size_column_wrap.rs index 7f2ca30cd..df6ac4015 100644 --- a/tests/generated/intrinsic_sizing_main_size_column_wrap.rs +++ b/tests/generated/intrinsic_sizing_main_size_column_wrap.rs @@ -3,61 +3,43 @@ fn intrinsic_sizing_main_size_column_wrap() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Vertical, - None, - ) - }), - ) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Vertical, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::Wrap, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Vertical, None) + }), + ); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Vertical, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/intrinsic_sizing_main_size_row.rs b/tests/generated/intrinsic_sizing_main_size_row.rs index 6ce888aa4..6d4235c5e 100644 --- a/tests/generated/intrinsic_sizing_main_size_row.rs +++ b/tests/generated/intrinsic_sizing_main_size_row.rs @@ -3,26 +3,18 @@ fn intrinsic_sizing_main_size_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/intrinsic_sizing_main_size_row_nested.rs b/tests/generated/intrinsic_sizing_main_size_row_nested.rs index 536dcd8be..5bfc1385f 100644 --- a/tests/generated/intrinsic_sizing_main_size_row_nested.rs +++ b/tests/generated/intrinsic_sizing_main_size_row_nested.rs @@ -3,32 +3,24 @@ fn intrinsic_sizing_main_size_row_nested() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/intrinsic_sizing_main_size_row_wrap.rs b/tests/generated/intrinsic_sizing_main_size_row_wrap.rs index d5fa20102..6398b1fe3 100644 --- a/tests/generated/intrinsic_sizing_main_size_row_wrap.rs +++ b/tests/generated/intrinsic_sizing_main_size_row_wrap.rs @@ -3,57 +3,39 @@ fn intrinsic_sizing_main_size_row_wrap() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x); diff --git a/tests/generated/justify_content_column_center.rs b/tests/generated/justify_content_column_center.rs index 3c4d887ef..b9007a866 100644 --- a/tests/generated/justify_content_column_center.rs +++ b/tests/generated/justify_content_column_center.rs @@ -3,58 +3,50 @@ fn justify_content_column_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 35f32, "y of node {:?}. Expected {}. Actual {}", node0, 35f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/justify_content_column_flex_end.rs b/tests/generated/justify_content_column_flex_end.rs index ea608edce..310ad1cd6 100644 --- a/tests/generated/justify_content_column_flex_end.rs +++ b/tests/generated/justify_content_column_flex_end.rs @@ -3,58 +3,50 @@ fn justify_content_column_flex_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - justify_content: Some(taffy::style::JustifyContent::FlexEnd), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::FlexEnd), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/justify_content_column_flex_start.rs b/tests/generated/justify_content_column_flex_start.rs index 594141875..6ed38211c 100644 --- a/tests/generated/justify_content_column_flex_start.rs +++ b/tests/generated/justify_content_column_flex_start.rs @@ -3,58 +3,50 @@ fn justify_content_column_flex_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - justify_content: Some(taffy::style::JustifyContent::FlexStart), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::FlexStart), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/justify_content_column_max_height_and_margin.rs b/tests/generated/justify_content_column_max_height_and_margin.rs index 759dcf4f5..bdb3866ec 100644 --- a/tests/generated/justify_content_column_max_height_and_margin.rs +++ b/tests/generated/justify_content_column_max_height_and_margin.rs @@ -3,49 +3,45 @@ fn justify_content_column_max_height_and_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(80f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(100f32), + bottom: zero(), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(80f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(100f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00], + ); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node, 180f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/justify_content_column_min_height_and_margin.rs b/tests/generated/justify_content_column_min_height_and_margin.rs index 004aa3cda..54f9315df 100644 --- a/tests/generated/justify_content_column_min_height_and_margin.rs +++ b/tests/generated/justify_content_column_min_height_and_margin.rs @@ -3,48 +3,44 @@ fn justify_content_column_min_height_and_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(100f32), + bottom: zero(), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - justify_content: Some(taffy::style::JustifyContent::Center), - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(100f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00], + ); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node, 150f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/justify_content_column_min_height_and_margin_bottom.rs b/tests/generated/justify_content_column_min_height_and_margin_bottom.rs index 5b2f766fc..3194a7145 100644 --- a/tests/generated/justify_content_column_min_height_and_margin_bottom.rs +++ b/tests/generated/justify_content_column_min_height_and_margin_bottom.rs @@ -3,42 +3,38 @@ fn justify_content_column_min_height_and_margin_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - justify_content: Some(taffy::style::JustifyContent::Center), - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/justify_content_column_min_height_and_margin_top.rs b/tests/generated/justify_content_column_min_height_and_margin_top.rs index dafac6293..0cdba9003 100644 --- a/tests/generated/justify_content_column_min_height_and_margin_top.rs +++ b/tests/generated/justify_content_column_min_height_and_margin_top.rs @@ -3,42 +3,38 @@ fn justify_content_column_min_height_and_margin_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - justify_content: Some(taffy::style::JustifyContent::Center), - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/justify_content_column_space_around.rs b/tests/generated/justify_content_column_space_around.rs index aca634d7f..366aded2d 100644 --- a/tests/generated/justify_content_column_space_around.rs +++ b/tests/generated/justify_content_column_space_around.rs @@ -3,58 +3,50 @@ fn justify_content_column_space_around() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - justify_content: Some(taffy::style::JustifyContent::SpaceAround), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::SpaceAround), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/justify_content_column_space_between.rs b/tests/generated/justify_content_column_space_between.rs index e1c90ffbe..0e015db6b 100644 --- a/tests/generated/justify_content_column_space_between.rs +++ b/tests/generated/justify_content_column_space_between.rs @@ -3,58 +3,50 @@ fn justify_content_column_space_between() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - justify_content: Some(taffy::style::JustifyContent::SpaceBetween), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/justify_content_column_space_evenly.rs b/tests/generated/justify_content_column_space_evenly.rs index d41f52044..2c4ca66c1 100644 --- a/tests/generated/justify_content_column_space_evenly.rs +++ b/tests/generated/justify_content_column_space_evenly.rs @@ -3,58 +3,50 @@ fn justify_content_column_space_evenly() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node0, 18f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node1, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/justify_content_min_max.rs b/tests/generated/justify_content_min_max.rs index d4329c99b..0727e15e2 100644 --- a/tests/generated/justify_content_min_max.rs +++ b/tests/generated/justify_content_min_max.rs @@ -3,38 +3,34 @@ fn justify_content_min_max() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(60f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(60f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs b/tests/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs index 0e4e98121..2a9346ffa 100644 --- a/tests/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs +++ b/tests/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs @@ -3,73 +3,65 @@ fn justify_content_min_width_with_padding_child_width_greater_than_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { + let node000 = taffy.new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(300f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(300f32), - height: taffy::style::Dimension::Length(100f32), + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(400f32), height: auto() }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(100f32), + right: taffy::style::LengthPercentage::Length(100f32), + top: zero(), + bottom: zero(), }, ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - align_content: Some(taffy::style::AlignContent::Stretch), - justify_content: Some(taffy::style::JustifyContent::Center), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(400f32), height: auto() }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(100f32), - right: taffy::style::LengthPercentage::Length(100f32), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(1000f32), - height: taffy::style::Dimension::Length(1584f32), - }, - ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(1000f32), + height: taffy::style::Dimension::Length(1584f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 1000f32, "width of node {:?}. Expected {}. Actual {}", node, 1000f32, size.width); assert_eq!(size.height, 1584f32, "height of node {:?}. Expected {}. Actual {}", node, 1584f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 1000f32, "width of node {:?}. Expected {}. Actual {}", node0, 1000f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node00, 500f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node000, 300f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node000, 100f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node000, 100f32, location.x); diff --git a/tests/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs b/tests/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs index a66a006ca..79f4cbf74 100644 --- a/tests/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs +++ b/tests/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs @@ -3,73 +3,65 @@ fn justify_content_min_width_with_padding_child_width_lower_than_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { + let node000 = taffy.new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(199f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(199f32), - height: taffy::style::Dimension::Length(100f32), + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(400f32), height: auto() }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(100f32), + right: taffy::style::LengthPercentage::Length(100f32), + top: zero(), + bottom: zero(), }, ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - align_content: Some(taffy::style::AlignContent::Stretch), - justify_content: Some(taffy::style::JustifyContent::Center), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(400f32), height: auto() }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(100f32), - right: taffy::style::LengthPercentage::Length(100f32), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(1080f32), - height: taffy::style::Dimension::Length(1584f32), - }, - ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(1080f32), + height: taffy::style::Dimension::Length(1584f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node, 1080f32, size.width); assert_eq!(size.height, 1584f32, "height of node {:?}. Expected {}. Actual {}", node, 1584f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node0, 1080f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node00, 400f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 199f32, "width of node {:?}. Expected {}. Actual {}", node000, 199f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node000, 100f32, size.height); assert_eq!(location.x, 101f32, "x of node {:?}. Expected {}. Actual {}", node000, 101f32, location.x); diff --git a/tests/generated/justify_content_overflow_min_max.rs b/tests/generated/justify_content_overflow_min_max.rs index e8980efac..51d819078 100644 --- a/tests/generated/justify_content_overflow_min_max.rs +++ b/tests/generated/justify_content_overflow_min_max.rs @@ -3,68 +3,60 @@ fn justify_content_overflow_min_max() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(110f32) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - justify_content: Some(taffy::style::JustifyContent::Center), - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(110f32) }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 110f32, "height of node {:?}. Expected {}. Actual {}", node, 110f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, -20f32, "y of node {:?}. Expected {}. Actual {}", node0, -20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/justify_content_row_center.rs b/tests/generated/justify_content_row_center.rs index 1f3d05e21..7aae5cf1d 100644 --- a/tests/generated/justify_content_row_center.rs +++ b/tests/generated/justify_content_row_center.rs @@ -3,57 +3,49 @@ fn justify_content_row_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node0, 35f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 55f32, "x of node {:?}. Expected {}. Actual {}", node2, 55f32, location.x); diff --git a/tests/generated/justify_content_row_flex_end.rs b/tests/generated/justify_content_row_flex_end.rs index 9c649b662..9f3698da3 100644 --- a/tests/generated/justify_content_row_flex_end.rs +++ b/tests/generated/justify_content_row_flex_end.rs @@ -3,57 +3,49 @@ fn justify_content_row_flex_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::FlexEnd), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::FlexEnd), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node0, 70f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node1, 80f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node2, 90f32, location.x); diff --git a/tests/generated/justify_content_row_flex_start.rs b/tests/generated/justify_content_row_flex_start.rs index 73f4d0a27..9e892cb68 100644 --- a/tests/generated/justify_content_row_flex_start.rs +++ b/tests/generated/justify_content_row_flex_start.rs @@ -3,57 +3,49 @@ fn justify_content_row_flex_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::FlexStart), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::FlexStart), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2, 20f32, location.x); diff --git a/tests/generated/justify_content_row_max_width_and_margin.rs b/tests/generated/justify_content_row_max_width_and_margin.rs index d18ac2023..759f753a4 100644 --- a/tests/generated/justify_content_row_max_width_and_margin.rs +++ b/tests/generated/justify_content_row_max_width_and_margin.rs @@ -3,42 +3,38 @@ fn justify_content_row_max_width_and_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(100f32), - right: zero(), - top: zero(), - bottom: zero(), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(100f32), + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(80f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(80f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node0, 90f32, location.x); diff --git a/tests/generated/justify_content_row_min_width_and_margin.rs b/tests/generated/justify_content_row_min_width_and_margin.rs index a271eed75..0afdf1ef7 100644 --- a/tests/generated/justify_content_row_min_width_and_margin.rs +++ b/tests/generated/justify_content_row_min_width_and_margin.rs @@ -3,41 +3,37 @@ fn justify_content_row_min_width_and_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: zero(), - top: zero(), - bottom: zero(), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::Center), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); diff --git a/tests/generated/justify_content_row_space_around.rs b/tests/generated/justify_content_row_space_around.rs index 695e94f4d..c8ec2fc39 100644 --- a/tests/generated/justify_content_row_space_around.rs +++ b/tests/generated/justify_content_row_space_around.rs @@ -3,57 +3,49 @@ fn justify_content_row_space_around() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::SpaceAround), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::SpaceAround), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 12f32, "x of node {:?}. Expected {}. Actual {}", node0, 12f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 78f32, "x of node {:?}. Expected {}. Actual {}", node2, 78f32, location.x); diff --git a/tests/generated/justify_content_row_space_between.rs b/tests/generated/justify_content_row_space_between.rs index 3ba5e955d..4b465722d 100644 --- a/tests/generated/justify_content_row_space_between.rs +++ b/tests/generated/justify_content_row_space_between.rs @@ -3,57 +3,49 @@ fn justify_content_row_space_between() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::SpaceBetween), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node1, 45f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node2, 90f32, location.x); diff --git a/tests/generated/justify_content_row_space_evenly.rs b/tests/generated/justify_content_row_space_evenly.rs index 16d783b12..a56d06f93 100644 --- a/tests/generated/justify_content_row_space_evenly.rs +++ b/tests/generated/justify_content_row_space_evenly.rs @@ -3,57 +3,49 @@ fn justify_content_row_space_evenly() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node0, 25f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node2, 75f32, location.x); diff --git a/tests/generated/leaf_overflow_scrollbars_affect_available_space_x_axis.rs b/tests/generated/leaf_overflow_scrollbars_affect_available_space_x_axis.rs index 7c67d130f..098bd18ef 100644 --- a/tests/generated/leaf_overflow_scrollbars_affect_available_space_x_axis.rs +++ b/tests/generated/leaf_overflow_scrollbars_affect_available_space_x_axis.rs @@ -3,37 +3,26 @@ fn leaf_overflow_scrollbars_affect_available_space_x_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Visible, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(45f32), - height: taffy::style::Dimension::Length(45f32), - }, - ..Default::default() + let node = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Visible }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(45f32), + height: taffy::style::Dimension::Length(45f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node, 45f32, size.width); assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node, 45f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/leaf_overflow_scrollbars_affect_available_space_y_axis.rs b/tests/generated/leaf_overflow_scrollbars_affect_available_space_y_axis.rs index d5eadd143..970fff02c 100644 --- a/tests/generated/leaf_overflow_scrollbars_affect_available_space_y_axis.rs +++ b/tests/generated/leaf_overflow_scrollbars_affect_available_space_y_axis.rs @@ -3,37 +3,26 @@ fn leaf_overflow_scrollbars_affect_available_space_y_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Visible, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(45f32), - height: taffy::style::Dimension::Length(45f32), - }, - ..Default::default() + let node = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(45f32), + height: taffy::style::Dimension::Length(45f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H\u{a0}H"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node, 45f32, size.width); assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node, 45f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/leaf_overflow_scrollbars_overriden_by_available_space.rs b/tests/generated/leaf_overflow_scrollbars_overriden_by_available_space.rs index 123e1e780..42a4e81a0 100644 --- a/tests/generated/leaf_overflow_scrollbars_overriden_by_available_space.rs +++ b/tests/generated/leaf_overflow_scrollbars_overriden_by_available_space.rs @@ -3,36 +3,32 @@ fn leaf_overflow_scrollbars_overriden_by_available_space() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, - scrollbar_width: 15f32, - flex_grow: 1f32, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(4f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + flex_grow: 1f32, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(4f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node0, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/leaf_overflow_scrollbars_overriden_by_max_size.rs b/tests/generated/leaf_overflow_scrollbars_overriden_by_max_size.rs index 68d8db518..35881c010 100644 --- a/tests/generated/leaf_overflow_scrollbars_overriden_by_max_size.rs +++ b/tests/generated/leaf_overflow_scrollbars_overriden_by_max_size.rs @@ -3,22 +3,20 @@ fn leaf_overflow_scrollbars_overriden_by_max_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, - scrollbar_width: 15f32, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(4f32), - }, - ..Default::default() - }) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(4f32), + }, + ..Default::default() + }); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/leaf_overflow_scrollbars_overriden_by_size.rs b/tests/generated/leaf_overflow_scrollbars_overriden_by_size.rs index 383a0ea0c..3c178fc0f 100644 --- a/tests/generated/leaf_overflow_scrollbars_overriden_by_size.rs +++ b/tests/generated/leaf_overflow_scrollbars_overriden_by_size.rs @@ -3,22 +3,20 @@ fn leaf_overflow_scrollbars_overriden_by_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(4f32), - }, - ..Default::default() - }) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(4f32), + }, + ..Default::default() + }); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/leaf_overflow_scrollbars_take_up_space_both_axis.rs b/tests/generated/leaf_overflow_scrollbars_take_up_space_both_axis.rs index fba8b3074..2704750c9 100644 --- a/tests/generated/leaf_overflow_scrollbars_take_up_space_both_axis.rs +++ b/tests/generated/leaf_overflow_scrollbars_take_up_space_both_axis.rs @@ -3,33 +3,22 @@ fn leaf_overflow_scrollbars_take_up_space_both_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node, 35f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node, 25f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/leaf_overflow_scrollbars_take_up_space_x_axis.rs b/tests/generated/leaf_overflow_scrollbars_take_up_space_x_axis.rs index e5a563365..244c0990e 100644 --- a/tests/generated/leaf_overflow_scrollbars_take_up_space_x_axis.rs +++ b/tests/generated/leaf_overflow_scrollbars_take_up_space_x_axis.rs @@ -3,33 +3,22 @@ fn leaf_overflow_scrollbars_take_up_space_x_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Visible, - }, - scrollbar_width: 15f32, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Visible }, + scrollbar_width: 15f32, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node, 25f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/leaf_overflow_scrollbars_take_up_space_y_axis.rs b/tests/generated/leaf_overflow_scrollbars_take_up_space_y_axis.rs index d7f00d9cc..6bf59d48f 100644 --- a/tests/generated/leaf_overflow_scrollbars_take_up_space_y_axis.rs +++ b/tests/generated/leaf_overflow_scrollbars_take_up_space_y_axis.rs @@ -3,33 +3,22 @@ fn leaf_overflow_scrollbars_take_up_space_y_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Visible, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node, 35f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/leaf_padding_border_overrides_max_size.rs b/tests/generated/leaf_padding_border_overrides_max_size.rs index 6cd76533d..07621c164 100644 --- a/tests/generated/leaf_padding_border_overrides_max_size.rs +++ b/tests/generated/leaf_padding_border_overrides_max_size.rs @@ -3,32 +3,30 @@ fn leaf_padding_border_overrides_max_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/leaf_padding_border_overrides_min_size.rs b/tests/generated/leaf_padding_border_overrides_min_size.rs index af01e10ec..f8cec9035 100644 --- a/tests/generated/leaf_padding_border_overrides_min_size.rs +++ b/tests/generated/leaf_padding_border_overrides_min_size.rs @@ -3,32 +3,30 @@ fn leaf_padding_border_overrides_min_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(0f32), - height: taffy::style::Dimension::Length(0f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(0f32), + height: taffy::style::Dimension::Length(0f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/leaf_padding_border_overrides_size.rs b/tests/generated/leaf_padding_border_overrides_size.rs index 480615037..0f491dcc8 100644 --- a/tests/generated/leaf_padding_border_overrides_size.rs +++ b/tests/generated/leaf_padding_border_overrides_size.rs @@ -3,32 +3,30 @@ fn leaf_padding_border_overrides_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/leaf_with_content_and_border.rs b/tests/generated/leaf_with_content_and_border.rs index 87a55e27c..b97b05c2a 100644 --- a/tests/generated/leaf_with_content_and_border.rs +++ b/tests/generated/leaf_with_content_and_border.rs @@ -3,34 +3,26 @@ fn leaf_with_content_and_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf_with_measure( - taffy::style::Style { - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node = taffy.new_leaf_with_measure( + taffy::style::Style { + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node, 18f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/leaf_with_content_and_padding.rs b/tests/generated/leaf_with_content_and_padding.rs index 7908c32b3..6eea0681d 100644 --- a/tests/generated/leaf_with_content_and_padding.rs +++ b/tests/generated/leaf_with_content_and_padding.rs @@ -3,34 +3,26 @@ fn leaf_with_content_and_padding() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf_with_measure( - taffy::style::Style { - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - ..Default::default() + let node = taffy.new_leaf_with_measure( + taffy::style::Style { + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node, 18f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/leaf_with_content_and_padding_border.rs b/tests/generated/leaf_with_content_and_padding_border.rs index ff28b11d3..47fa41f4f 100644 --- a/tests/generated/leaf_with_content_and_padding_border.rs +++ b/tests/generated/leaf_with_content_and_padding_border.rs @@ -3,40 +3,32 @@ fn leaf_with_content_and_padding_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf_with_measure( - taffy::style::Style { - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() + let node = taffy.new_leaf_with_measure( + taffy::style::Style { + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node, 62f32, size.width); assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node, 24f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/margin_and_flex_column.rs b/tests/generated/margin_and_flex_column.rs index 5c8846b5e..1ad565d0e 100644 --- a/tests/generated/margin_and_flex_column.rs +++ b/tests/generated/margin_and_flex_column.rs @@ -3,41 +3,37 @@ fn margin_and_flex_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/margin_and_flex_row.rs b/tests/generated/margin_and_flex_row.rs index 41b14f2e5..ed4613580 100644 --- a/tests/generated/margin_and_flex_row.rs +++ b/tests/generated/margin_and_flex_row.rs @@ -3,40 +3,36 @@ fn margin_and_flex_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: zero(), - bottom: zero(), + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/margin_and_stretch_column.rs b/tests/generated/margin_and_stretch_column.rs index 5adc9957d..26121b921 100644 --- a/tests/generated/margin_and_stretch_column.rs +++ b/tests/generated/margin_and_stretch_column.rs @@ -3,41 +3,37 @@ fn margin_and_stretch_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: zero(), - bottom: zero(), + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/margin_and_stretch_row.rs b/tests/generated/margin_and_stretch_row.rs index 0d27f2831..a02616750 100644 --- a/tests/generated/margin_and_stretch_row.rs +++ b/tests/generated/margin_and_stretch_row.rs @@ -3,40 +3,36 @@ fn margin_and_stretch_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/margin_auto_bottom.rs b/tests/generated/margin_auto_bottom.rs index de5fccb3e..313e1ee7c 100644 --- a/tests/generated/margin_auto_bottom.rs +++ b/tests/generated/margin_auto_bottom.rs @@ -3,58 +3,52 @@ fn margin_auto_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Auto, + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); diff --git a/tests/generated/margin_auto_bottom_and_top.rs b/tests/generated/margin_auto_bottom_and_top.rs index f3da0f799..e42dd52b6 100644 --- a/tests/generated/margin_auto_bottom_and_top.rs +++ b/tests/generated/margin_auto_bottom_and_top.rs @@ -3,58 +3,52 @@ fn margin_auto_bottom_and_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); diff --git a/tests/generated/margin_auto_bottom_and_top_justify_center.rs b/tests/generated/margin_auto_bottom_and_top_justify_center.rs index 606eff6d8..bf1d80281 100644 --- a/tests/generated/margin_auto_bottom_and_top_justify_center.rs +++ b/tests/generated/margin_auto_bottom_and_top_justify_center.rs @@ -3,58 +3,52 @@ fn margin_auto_bottom_and_top_justify_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); diff --git a/tests/generated/margin_auto_left.rs b/tests/generated/margin_auto_left.rs index 0700cc9ee..c2bd4260a 100644 --- a/tests/generated/margin_auto_left.rs +++ b/tests/generated/margin_auto_left.rs @@ -3,58 +3,52 @@ fn margin_auto_left() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: zero(), - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node0, 100f32, location.x); assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); diff --git a/tests/generated/margin_auto_left_and_right.rs b/tests/generated/margin_auto_left_and_right.rs index d9d01e6b9..9c3279964 100644 --- a/tests/generated/margin_auto_left_and_right.rs +++ b/tests/generated/margin_auto_left_and_right.rs @@ -3,57 +3,51 @@ fn margin_auto_left_and_right() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); diff --git a/tests/generated/margin_auto_left_and_right_column.rs b/tests/generated/margin_auto_left_and_right_column.rs index aa5fa5346..7916b2680 100644 --- a/tests/generated/margin_auto_left_and_right_column.rs +++ b/tests/generated/margin_auto_left_and_right_column.rs @@ -3,58 +3,52 @@ fn margin_auto_left_and_right_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); diff --git a/tests/generated/margin_auto_left_and_right_column_and_center.rs b/tests/generated/margin_auto_left_and_right_column_and_center.rs index 7f0770f9b..e5bac6897 100644 --- a/tests/generated/margin_auto_left_and_right_column_and_center.rs +++ b/tests/generated/margin_auto_left_and_right_column_and_center.rs @@ -3,58 +3,52 @@ fn margin_auto_left_and_right_column_and_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); diff --git a/tests/generated/margin_auto_left_and_right_stretch.rs b/tests/generated/margin_auto_left_and_right_stretch.rs index dbb84eb41..72b8c9a81 100644 --- a/tests/generated/margin_auto_left_and_right_stretch.rs +++ b/tests/generated/margin_auto_left_and_right_stretch.rs @@ -3,58 +3,52 @@ fn margin_auto_left_and_right_stretch() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Stretch), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); diff --git a/tests/generated/margin_auto_left_child_bigger_than_parent.rs b/tests/generated/margin_auto_left_child_bigger_than_parent.rs index a7608a4f4..b0e1047ec 100644 --- a/tests/generated/margin_auto_left_child_bigger_than_parent.rs +++ b/tests/generated/margin_auto_left_child_bigger_than_parent.rs @@ -3,44 +3,40 @@ fn margin_auto_left_child_bigger_than_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(72f32), + height: taffy::style::Dimension::Length(72f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(72f32), - height: taffy::style::Dimension::Length(72f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: zero(), - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(52f32), + height: taffy::style::Dimension::Length(52f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(52f32), - height: taffy::style::Dimension::Length(52f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0, 52f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs b/tests/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs index 06e5197ce..2f5a0a269 100644 --- a/tests/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs +++ b/tests/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs @@ -3,44 +3,40 @@ fn margin_auto_left_fix_right_child_bigger_than_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(72f32), + height: taffy::style::Dimension::Length(72f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(72f32), - height: taffy::style::Dimension::Length(72f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(52f32), + height: taffy::style::Dimension::Length(52f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(52f32), - height: taffy::style::Dimension::Length(52f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 42f32, "width of node {:?}. Expected {}. Actual {}", node0, 42f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/margin_auto_left_right_child_bigger_than_parent.rs b/tests/generated/margin_auto_left_right_child_bigger_than_parent.rs index 5947c97c3..85d1305b7 100644 --- a/tests/generated/margin_auto_left_right_child_bigger_than_parent.rs +++ b/tests/generated/margin_auto_left_right_child_bigger_than_parent.rs @@ -3,44 +3,40 @@ fn margin_auto_left_right_child_bigger_than_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(72f32), + height: taffy::style::Dimension::Length(72f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(72f32), - height: taffy::style::Dimension::Length(72f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(52f32), + height: taffy::style::Dimension::Length(52f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(52f32), - height: taffy::style::Dimension::Length(52f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0, 52f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/margin_auto_left_stretching_child.rs b/tests/generated/margin_auto_left_stretching_child.rs index 2e3d9e71e..d0f5df710 100644 --- a/tests/generated/margin_auto_left_stretching_child.rs +++ b/tests/generated/margin_auto_left_stretching_child.rs @@ -3,57 +3,51 @@ fn margin_auto_left_stretching_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: zero(), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node0, 150f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); diff --git a/tests/generated/margin_auto_mutiple_children_column.rs b/tests/generated/margin_auto_mutiple_children_column.rs index 09c5e771a..0eeb00ac2 100644 --- a/tests/generated/margin_auto_mutiple_children_column.rs +++ b/tests/generated/margin_auto_mutiple_children_column.rs @@ -3,79 +3,71 @@ fn margin_auto_mutiple_children_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node0, 75f32, location.x); assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node0, 25f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node1, 75f32, location.x); assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node1, 100f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node2, 75f32, location.x); diff --git a/tests/generated/margin_auto_mutiple_children_row.rs b/tests/generated/margin_auto_mutiple_children_row.rs index 7ff9941bd..3b3f30258 100644 --- a/tests/generated/margin_auto_mutiple_children_row.rs +++ b/tests/generated/margin_auto_mutiple_children_row.rs @@ -3,78 +3,70 @@ fn margin_auto_mutiple_children_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node1, 75f32, location.x); assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node1, 75f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height); assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node2, 150f32, location.x); diff --git a/tests/generated/margin_auto_right.rs b/tests/generated/margin_auto_right.rs index a57e00da5..72661479b 100644 --- a/tests/generated/margin_auto_right.rs +++ b/tests/generated/margin_auto_right.rs @@ -3,58 +3,52 @@ fn margin_auto_right() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); diff --git a/tests/generated/margin_auto_top.rs b/tests/generated/margin_auto_top.rs index b3a9b78c5..d17ab946c 100644 --- a/tests/generated/margin_auto_top.rs +++ b/tests/generated/margin_auto_top.rs @@ -3,58 +3,52 @@ fn margin_auto_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: zero(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node0, 150f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); diff --git a/tests/generated/margin_auto_top_and_bottom_stretch.rs b/tests/generated/margin_auto_top_and_bottom_stretch.rs index 786c58960..8ad3b27e3 100644 --- a/tests/generated/margin_auto_top_and_bottom_stretch.rs +++ b/tests/generated/margin_auto_top_and_bottom_stretch.rs @@ -3,59 +3,53 @@ fn margin_auto_top_and_bottom_stretch() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Stretch), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Stretch), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node0, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/margin_auto_top_stretching_child.rs b/tests/generated/margin_auto_top_stretching_child.rs index 4f9b4a4be..d79f3cec2 100644 --- a/tests/generated/margin_auto_top_stretching_child.rs +++ b/tests/generated/margin_auto_top_stretching_child.rs @@ -3,57 +3,51 @@ fn margin_auto_top_stretching_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Auto, - bottom: zero(), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node0, 150f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node0, 200f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 150f32, "x of node {:?}. Expected {}. Actual {}", node1, 150f32, location.x); diff --git a/tests/generated/margin_bottom.rs b/tests/generated/margin_bottom.rs index 79b9de164..caa6b22c4 100644 --- a/tests/generated/margin_bottom.rs +++ b/tests/generated/margin_bottom.rs @@ -3,42 +3,38 @@ fn margin_bottom() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::FlexEnd), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - justify_content: Some(taffy::style::JustifyContent::FlexEnd), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs b/tests/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs index 546b1a1e2..d063ef0b7 100644 --- a/tests/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs +++ b/tests/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs @@ -3,44 +3,40 @@ fn margin_fix_left_auto_right_child_bigger_than_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(72f32), + height: taffy::style::Dimension::Length(72f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(72f32), - height: taffy::style::Dimension::Length(72f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: taffy::style::LengthPercentageAuto::Auto, - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(52f32), + height: taffy::style::Dimension::Length(52f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(52f32), - height: taffy::style::Dimension::Length(52f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 42f32, "width of node {:?}. Expected {}. Actual {}", node0, 42f32, size.width); assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0, 72f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/margin_left.rs b/tests/generated/margin_left.rs index ccfa05ca8..03fac589a 100644 --- a/tests/generated/margin_left.rs +++ b/tests/generated/margin_left.rs @@ -3,40 +3,36 @@ fn margin_left() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(10f32), - right: zero(), - top: zero(), - bottom: zero(), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(10f32), + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/margin_right.rs b/tests/generated/margin_right.rs index c8dc5e64c..a9747ffc4 100644 --- a/tests/generated/margin_right.rs +++ b/tests/generated/margin_right.rs @@ -3,41 +3,37 @@ fn margin_right() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: zero(), - bottom: zero(), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::FlexEnd), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::FlexEnd), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); diff --git a/tests/generated/margin_should_not_be_part_of_max_height.rs b/tests/generated/margin_should_not_be_part_of_max_height.rs index c53edf8b0..fcc3fc7e4 100644 --- a/tests/generated/margin_should_not_be_part_of_max_height.rs +++ b/tests/generated/margin_should_not_be_part_of_max_height.rs @@ -3,44 +3,40 @@ fn margin_should_not_be_part_of_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(20f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(20f32), - bottom: zero(), + width: taffy::style::Dimension::Length(250f32), + height: taffy::style::Dimension::Length(250f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(250f32), - height: taffy::style::Dimension::Length(250f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node, 250f32, size.width); assert_eq!(size.height, 250f32, "height of node {:?}. Expected {}. Actual {}", node, 250f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/margin_should_not_be_part_of_max_width.rs b/tests/generated/margin_should_not_be_part_of_max_width.rs index ccc296241..3e43c03fd 100644 --- a/tests/generated/margin_should_not_be_part_of_max_width.rs +++ b/tests/generated/margin_should_not_be_part_of_max_width.rs @@ -3,44 +3,40 @@ fn margin_should_not_be_part_of_max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(20f32), + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(20f32), - right: zero(), - top: zero(), - bottom: zero(), + width: taffy::style::Dimension::Length(250f32), + height: taffy::style::Dimension::Length(250f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(250f32), - height: taffy::style::Dimension::Length(250f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node, 250f32, size.width); assert_eq!(size.height, 250f32, "height of node {:?}. Expected {}. Actual {}", node, 250f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); diff --git a/tests/generated/margin_top.rs b/tests/generated/margin_top.rs index 87d73301b..dc5efb380 100644 --- a/tests/generated/margin_top.rs +++ b/tests/generated/margin_top.rs @@ -3,41 +3,37 @@ fn margin_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/margin_with_sibling_column.rs b/tests/generated/margin_with_sibling_column.rs index 633b11a19..be2cf615f 100644 --- a/tests/generated/margin_with_sibling_column.rs +++ b/tests/generated/margin_with_sibling_column.rs @@ -3,47 +3,43 @@ fn margin_with_sibling_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node0, 45f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 45f32, "height of node {:?}. Expected {}. Actual {}", node1, 45f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/margin_with_sibling_row.rs b/tests/generated/margin_with_sibling_row.rs index 3c5d6fc04..0937ded60 100644 --- a/tests/generated/margin_with_sibling_row.rs +++ b/tests/generated/margin_with_sibling_row.rs @@ -3,46 +3,42 @@ fn margin_with_sibling_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: zero(), - bottom: zero(), + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node0, 45f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 45f32, "width of node {:?}. Expected {}. Actual {}", node1, 45f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 55f32, "x of node {:?}. Expected {}. Actual {}", node1, 55f32, location.x); diff --git a/tests/generated/max_height.rs b/tests/generated/max_height.rs index 743930728..5a22b72a2 100644 --- a/tests/generated/max_height.rs +++ b/tests/generated/max_height.rs @@ -3,35 +3,31 @@ fn max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/max_height_overrides_height.rs b/tests/generated/max_height_overrides_height.rs index 7c2120ce3..e2c5e6e43 100644 --- a/tests/generated/max_height_overrides_height.rs +++ b/tests/generated/max_height_overrides_height.rs @@ -3,24 +3,22 @@ fn max_height_overrides_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/max_height_overrides_height_on_root.rs b/tests/generated/max_height_overrides_height_on_root.rs index 45c7166fa..5864b32ed 100644 --- a/tests/generated/max_height_overrides_height_on_root.rs +++ b/tests/generated/max_height_overrides_height_on_root.rs @@ -3,18 +3,16 @@ fn max_height_overrides_height_on_root() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + ..Default::default() + }); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/max_width.rs b/tests/generated/max_width.rs index 347da7fc9..c020e4f67 100644 --- a/tests/generated/max_width.rs +++ b/tests/generated/max_width.rs @@ -3,36 +3,32 @@ fn max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/max_width_overrides_width.rs b/tests/generated/max_width_overrides_width.rs index 213df31b3..7d64f7350 100644 --- a/tests/generated/max_width_overrides_width.rs +++ b/tests/generated/max_width_overrides_width.rs @@ -3,24 +3,22 @@ fn max_width_overrides_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/max_width_overrides_width_on_root.rs b/tests/generated/max_width_overrides_width_on_root.rs index 2f0fe6a56..aec428754 100644 --- a/tests/generated/max_width_overrides_width_on_root.rs +++ b/tests/generated/max_width_overrides_width_on_root.rs @@ -3,18 +3,16 @@ fn max_width_overrides_width_on_root() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/measure_child.rs b/tests/generated/measure_child.rs index d28b97794..64d2c990b 100644 --- a/tests/generated/measure_child.rs +++ b/tests/generated/measure_child.rs @@ -3,32 +3,24 @@ fn measure_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/measure_child_absolute.rs b/tests/generated/measure_child_absolute.rs index b90d4c842..589af4211 100644 --- a/tests/generated/measure_child_absolute.rs +++ b/tests/generated/measure_child_absolute.rs @@ -3,43 +3,33 @@ fn measure_child_absolute() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/measure_child_constraint.rs b/tests/generated/measure_child_constraint.rs index 88cb3ddb9..307d05337 100644 --- a/tests/generated/measure_child_constraint.rs +++ b/tests/generated/measure_child_constraint.rs @@ -3,29 +3,27 @@ fn measure_child_constraint() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , None) }) ,) . unwrap () ; - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Auto, - }, - ..Default::default() + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , None) }) ,) ; + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Auto, }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/measure_child_constraint_padding_parent.rs b/tests/generated/measure_child_constraint_padding_parent.rs index f12dfd345..03cfc1dde 100644 --- a/tests/generated/measure_child_constraint_padding_parent.rs +++ b/tests/generated/measure_child_constraint_padding_parent.rs @@ -3,35 +3,33 @@ fn measure_child_constraint_padding_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , None) }) ,) . unwrap () ; - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Auto, - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , None) }) ,) ; + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Auto, }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), + }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/measure_child_with_flex_grow.rs b/tests/generated/measure_child_with_flex_grow.rs index 4b95b55a6..2860335c9 100644 --- a/tests/generated/measure_child_with_flex_grow.rs +++ b/tests/generated/measure_child_with_flex_grow.rs @@ -3,57 +3,45 @@ fn measure_child_with_flex_grow() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "H\u{200b}H\u{200b}H\u{200b}H\u{200b}H"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Auto, }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "H\u{200b}H\u{200b}H\u{200b}H\u{200b}H"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Auto, - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); diff --git a/tests/generated/measure_child_with_flex_shrink.rs b/tests/generated/measure_child_with_flex_shrink.rs index 705b4e980..33a20f1af 100644 --- a/tests/generated/measure_child_with_flex_shrink.rs +++ b/tests/generated/measure_child_with_flex_shrink.rs @@ -3,57 +3,45 @@ fn measure_child_with_flex_shrink() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Auto, }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Auto, - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/measure_child_with_flex_shrink_hidden.rs b/tests/generated/measure_child_with_flex_shrink_hidden.rs index aa5462987..105cc7ef2 100644 --- a/tests/generated/measure_child_with_flex_shrink_hidden.rs +++ b/tests/generated/measure_child_with_flex_shrink_hidden.rs @@ -3,64 +3,49 @@ fn measure_child_with_flex_shrink_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Auto, }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Auto, - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node0, 9f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 91f32, "width of node {:?}. Expected {}. Actual {}", node1, 91f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height); assert_eq!(location.x, 9f32, "x of node {:?}. Expected {}. Actual {}", node1, 9f32, location.x); diff --git a/tests/generated/measure_child_with_min_size_greater_than_available_space.rs b/tests/generated/measure_child_with_min_size_greater_than_available_space.rs index 505f3299a..fc7df5ab7 100644 --- a/tests/generated/measure_child_with_min_size_greater_than_available_space.rs +++ b/tests/generated/measure_child_with_min_size_greater_than_available_space.rs @@ -3,45 +3,35 @@ fn measure_child_with_min_size_greater_than_available_space() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHH\u{200b}HHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHH\u{200b}HHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/measure_flex_basis_overrides_measure.rs b/tests/generated/measure_flex_basis_overrides_measure.rs index 50c56930d..f78887397 100644 --- a/tests/generated/measure_flex_basis_overrides_measure.rs +++ b/tests/generated/measure_flex_basis_overrides_measure.rs @@ -3,43 +3,33 @@ fn measure_flex_basis_overrides_measure() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "H"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "H"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/measure_height_overrides_measure.rs b/tests/generated/measure_height_overrides_measure.rs index 24a30e81d..7b2e9c731 100644 --- a/tests/generated/measure_height_overrides_measure.rs +++ b/tests/generated/measure_height_overrides_measure.rs @@ -3,35 +3,27 @@ fn measure_height_overrides_measure() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(5f32) }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "H"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(5f32) }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "H"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); assert_eq!(size.height, 5f32, "height of node {:?}. Expected {}. Actual {}", node, 5f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 5f32, "height of node {:?}. Expected {}. Actual {}", node0, 5f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/measure_remeasure_child_after_growing.rs b/tests/generated/measure_remeasure_child_after_growing.rs index 9be61a920..78a2c3c48 100644 --- a/tests/generated/measure_remeasure_child_after_growing.rs +++ b/tests/generated/measure_remeasure_child_after_growing.rs @@ -3,58 +3,46 @@ fn measure_remeasure_child_after_growing() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Auto, }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Auto, - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); diff --git a/tests/generated/measure_remeasure_child_after_shrinking.rs b/tests/generated/measure_remeasure_child_after_shrinking.rs index b445d05d9..e183b6707 100644 --- a/tests/generated/measure_remeasure_child_after_shrinking.rs +++ b/tests/generated/measure_remeasure_child_after_shrinking.rs @@ -3,59 +3,47 @@ fn measure_remeasure_child_after_shrinking() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, + let node0 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Auto, }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Start), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Auto, - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); diff --git a/tests/generated/measure_remeasure_child_after_stretching.rs b/tests/generated/measure_remeasure_child_after_stretching.rs index 3b7a3d9e9..b02338627 100644 --- a/tests/generated/measure_remeasure_child_after_stretching.rs +++ b/tests/generated/measure_remeasure_child_after_stretching.rs @@ -3,43 +3,33 @@ fn measure_remeasure_child_after_stretching() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/measure_root.rs b/tests/generated/measure_root.rs index f4e80281a..713473a06 100644 --- a/tests/generated/measure_root.rs +++ b/tests/generated/measure_root.rs @@ -3,26 +3,18 @@ fn measure_root() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf_with_measure( - taffy::style::Style { ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/measure_stretch_overrides_measure.rs b/tests/generated/measure_stretch_overrides_measure.rs index 2b18c8909..ae1dd6306 100644 --- a/tests/generated/measure_stretch_overrides_measure.rs +++ b/tests/generated/measure_stretch_overrides_measure.rs @@ -3,59 +3,47 @@ fn measure_stretch_overrides_measure() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(5f32), + ..Default::default() + }); + let node1 = taffy.new_leaf_with_measure( + taffy::style::Style { flex_grow: 1f32, flex_basis: taffy::style::Dimension::Length(5f32), ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf_with_measure( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(5f32), - ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "H"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(10f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "H"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x); diff --git a/tests/generated/measure_width_overrides_measure.rs b/tests/generated/measure_width_overrides_measure.rs index af3d30259..6d4a67a28 100644 --- a/tests/generated/measure_width_overrides_measure.rs +++ b/tests/generated/measure_width_overrides_measure.rs @@ -3,35 +3,27 @@ fn measure_width_overrides_measure() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/min_height.rs b/tests/generated/min_height.rs index 5b2f4d948..3b8bc960c 100644 --- a/tests/generated/min_height.rs +++ b/tests/generated/min_height.rs @@ -3,42 +3,38 @@ fn min_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(60f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(60f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/min_height_larger_than_height.rs b/tests/generated/min_height_larger_than_height.rs index 4a51b8a64..073e7c6cf 100644 --- a/tests/generated/min_height_larger_than_height.rs +++ b/tests/generated/min_height_larger_than_height.rs @@ -3,35 +3,31 @@ fn min_height_larger_than_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(25f32) }, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(25f32) }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/min_height_overrides_height.rs b/tests/generated/min_height_overrides_height.rs index 65060b4d8..8616d9e4a 100644 --- a/tests/generated/min_height_overrides_height.rs +++ b/tests/generated/min_height_overrides_height.rs @@ -3,24 +3,22 @@ fn min_height_overrides_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/min_height_overrides_height_on_root.rs b/tests/generated/min_height_overrides_height_on_root.rs index f2a92537b..8b3e8ebe7 100644 --- a/tests/generated/min_height_overrides_height_on_root.rs +++ b/tests/generated/min_height_overrides_height_on_root.rs @@ -3,18 +3,16 @@ fn min_height_overrides_height_on_root() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - ..Default::default() - }) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + ..Default::default() + }); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/min_height_overrides_max_height.rs b/tests/generated/min_height_overrides_max_height.rs index 9a16f2a7a..643f5d035 100644 --- a/tests/generated/min_height_overrides_max_height.rs +++ b/tests/generated/min_height_overrides_max_height.rs @@ -3,24 +3,22 @@ fn min_height_overrides_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/min_height_with_nested_fixed_height.rs b/tests/generated/min_height_with_nested_fixed_height.rs index dfda2503d..7ae5b70c4 100644 --- a/tests/generated/min_height_with_nested_fixed_height.rs +++ b/tests/generated/min_height_with_nested_fixed_height.rs @@ -3,64 +3,58 @@ fn min_height_with_nested_fixed_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(40f32), + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_self: Some(taffy::style::AlignSelf::FlexStart), + flex_shrink: 0f32, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(28f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(8f32), + bottom: taffy::style::LengthPercentageAuto::Length(9f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_self: Some(taffy::style::AlignSelf::FlexStart), - flex_shrink: 0f32, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(28f32) }, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(8f32), - bottom: taffy::style::LengthPercentageAuto::Length(9f32), - }, - ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(320f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(44f32) }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(16f32), + right: taffy::style::LengthPercentage::Length(16f32), + top: zero(), + bottom: zero(), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(320f32), height: auto() }, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(44f32) }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(16f32), - right: taffy::style::LengthPercentage::Length(16f32), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); assert_eq!(size.height, 57f32, "height of node {:?}. Expected {}. Actual {}", node, 57f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height); assert_eq!(location.x, 16f32, "x of node {:?}. Expected {}. Actual {}", node0, 16f32, location.x); assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/min_max_percent_different_width_height.rs b/tests/generated/min_max_percent_different_width_height.rs index 585a10991..3ffd808a7 100644 --- a/tests/generated/min_max_percent_different_width_height.rs +++ b/tests/generated/min_max_percent_different_width_height.rs @@ -3,55 +3,45 @@ fn min_max_percent_different_width_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.1f32), - height: taffy::style::Dimension::Percent(0.1f32), - }, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.1f32), - height: taffy::style::Dimension::Percent(0.1f32), - }, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.1f32), + height: taffy::style::Dimension::Percent(0.1f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "\n "; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::FlexStart), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.1f32), + height: taffy::style::Dimension::Percent(0.1f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "\n "; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::FlexStart), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(200f32), + }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/min_max_percent_no_width_height.rs b/tests/generated/min_max_percent_no_width_height.rs index 220eeaf41..b85753689 100644 --- a/tests/generated/min_max_percent_no_width_height.rs +++ b/tests/generated/min_max_percent_no_width_height.rs @@ -3,43 +3,39 @@ fn min_max_percent_no_width_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.1f32), - height: taffy::style::Dimension::Percent(0.1f32), - }, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.1f32), - height: taffy::style::Dimension::Percent(0.1f32), + let node0 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.1f32), + height: taffy::style::Dimension::Percent(0.1f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.1f32), + height: taffy::style::Dimension::Percent(0.1f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::FlexStart), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::FlexStart), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/min_width.rs b/tests/generated/min_width.rs index 58fa12bd2..44cd9234d 100644 --- a/tests/generated/min_width.rs +++ b/tests/generated/min_width.rs @@ -3,41 +3,37 @@ fn min_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x); diff --git a/tests/generated/min_width_larger_than_width.rs b/tests/generated/min_width_larger_than_width.rs index 11f4e29f0..4e7da623f 100644 --- a/tests/generated/min_width_larger_than_width.rs +++ b/tests/generated/min_width_larger_than_width.rs @@ -3,36 +3,32 @@ fn min_width_larger_than_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(25f32), height: auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(25f32), height: auto() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/min_width_overrides_max_width.rs b/tests/generated/min_width_overrides_max_width.rs index 2abe32e85..ac383975c 100644 --- a/tests/generated/min_width_overrides_max_width.rs +++ b/tests/generated/min_width_overrides_max_width.rs @@ -3,24 +3,22 @@ fn min_width_overrides_max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/min_width_overrides_width.rs b/tests/generated/min_width_overrides_width.rs index 1312f14f7..4ce79b9eb 100644 --- a/tests/generated/min_width_overrides_width.rs +++ b/tests/generated/min_width_overrides_width.rs @@ -3,24 +3,22 @@ fn min_width_overrides_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/min_width_overrides_width_on_root.rs b/tests/generated/min_width_overrides_width_on_root.rs index 2cc14915c..9b0a89b40 100644 --- a/tests/generated/min_width_overrides_width_on_root.rs +++ b/tests/generated/min_width_overrides_width_on_root.rs @@ -3,18 +3,16 @@ fn min_width_overrides_width_on_root() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/nested_overflowing_child.rs b/tests/generated/nested_overflowing_child.rs index 6eb9664a3..bcc230c20 100644 --- a/tests/generated/nested_overflowing_child.rs +++ b/tests/generated/nested_overflowing_child.rs @@ -3,43 +3,39 @@ fn nested_overflowing_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node00, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/nested_overflowing_child_in_constraint_parent.rs b/tests/generated/nested_overflowing_child_in_constraint_parent.rs index 5b80d4192..6e337eb33 100644 --- a/tests/generated/nested_overflowing_child_in_constraint_parent.rs +++ b/tests/generated/nested_overflowing_child_in_constraint_parent.rs @@ -3,54 +3,48 @@ fn nested_overflowing_child_in_constraint_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/only_shrinkable_item_with_flex_basis_zero.rs b/tests/generated/only_shrinkable_item_with_flex_basis_zero.rs index e7828ef09..85c26c078 100644 --- a/tests/generated/only_shrinkable_item_with_flex_basis_zero.rs +++ b/tests/generated/only_shrinkable_item_with_flex_basis_zero.rs @@ -3,64 +3,56 @@ fn only_shrinkable_item_with_flex_basis_zero() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Length(0f32), + let node0 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Length(0f32), + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Length(93f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(6f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Length(764f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(480f32), height: auto() }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(764f32) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Length(93f32), - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: zero(), - bottom: taffy::style::LengthPercentageAuto::Length(6f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Length(764f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(480f32), height: auto() }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(764f32) }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 480f32, "width of node {:?}. Expected {}. Actual {}", node, 480f32, size.width); assert_eq!(size.height, 764f32, "height of node {:?}. Expected {}. Actual {}", node, 764f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 480f32, "width of node {:?}. Expected {}. Actual {}", node0, 480f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 480f32, "width of node {:?}. Expected {}. Actual {}", node1, 480f32, size.width); assert_eq!(size.height, 93f32, "height of node {:?}. Expected {}. Actual {}", node1, 93f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 480f32, "width of node {:?}. Expected {}. Actual {}", node2, 480f32, size.width); assert_eq!(size.height, 764f32, "height of node {:?}. Expected {}. Actual {}", node2, 764f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/overflow_cross_axis.rs b/tests/generated/overflow_cross_axis.rs index b6371d1df..70b7ffdfa 100644 --- a/tests/generated/overflow_cross_axis.rs +++ b/tests/generated/overflow_cross_axis.rs @@ -3,37 +3,33 @@ fn overflow_cross_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(200f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/overflow_main_axis.rs b/tests/generated/overflow_main_axis.rs index e86bfbec5..780fb5520 100644 --- a/tests/generated/overflow_main_axis.rs +++ b/tests/generated/overflow_main_axis.rs @@ -3,35 +3,31 @@ fn overflow_main_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/overflow_main_axis_shrink_hidden.rs b/tests/generated/overflow_main_axis_shrink_hidden.rs index ba2ace05c..e3530cdef 100644 --- a/tests/generated/overflow_main_axis_shrink_hidden.rs +++ b/tests/generated/overflow_main_axis_shrink_hidden.rs @@ -3,51 +3,38 @@ fn overflow_main_axis_shrink_hidden() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Hidden, - y: taffy::style::Overflow::Hidden, - }, - scrollbar_width: 15f32, - flex_shrink: 1f32, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + flex_shrink: 1f32, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/overflow_main_axis_shrink_scroll.rs b/tests/generated/overflow_main_axis_shrink_scroll.rs index 2a7bcf504..b1b9beb0b 100644 --- a/tests/generated/overflow_main_axis_shrink_scroll.rs +++ b/tests/generated/overflow_main_axis_shrink_scroll.rs @@ -3,51 +3,38 @@ fn overflow_main_axis_shrink_scroll() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - flex_shrink: 1f32, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + flex_shrink: 1f32, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/overflow_main_axis_shrink_visible.rs b/tests/generated/overflow_main_axis_shrink_visible.rs index 2fe4be6b1..2e1aa0dfc 100644 --- a/tests/generated/overflow_main_axis_shrink_visible.rs +++ b/tests/generated/overflow_main_axis_shrink_visible.rs @@ -3,43 +3,33 @@ fn overflow_main_axis_shrink_visible() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf_with_measure( - taffy::style::Style { flex_shrink: 1f32, ..Default::default() }, - taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { - const TEXT: &str = "HHHHHHHHHH"; - super::measure_standard_text( - known_dimensions, - available_space, - TEXT, - super::WritingMode::Horizontal, - None, - ) - }), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + let node0 = taffy.new_leaf_with_measure( + taffy::style::Style { flex_shrink: 1f32, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHHHHHHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal, None) + }), + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/overflow_scroll_main_axis_justify_content_end.rs b/tests/generated/overflow_scroll_main_axis_justify_content_end.rs index 15f1d18b4..aa02f0456 100644 --- a/tests/generated/overflow_scroll_main_axis_justify_content_end.rs +++ b/tests/generated/overflow_scroll_main_axis_justify_content_end.rs @@ -3,36 +3,32 @@ fn overflow_scroll_main_axis_justify_content_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::End), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, -100f32, "x of node {:?}. Expected {}. Actual {}", node0, -100f32, location.x); diff --git a/tests/generated/overflow_scrollbars_overriden_by_available_space.rs b/tests/generated/overflow_scrollbars_overriden_by_available_space.rs index 2b7bf96a5..7942309fa 100644 --- a/tests/generated/overflow_scrollbars_overriden_by_available_space.rs +++ b/tests/generated/overflow_scrollbars_overriden_by_available_space.rs @@ -3,48 +3,41 @@ fn overflow_scrollbars_overriden_by_available_space() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - flex_grow: 1f32, - ..Default::default() + let node00 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node0 = taffy.new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + flex_grow: 1f32, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(4f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(4f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node0, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/overflow_scrollbars_overriden_by_max_size.rs b/tests/generated/overflow_scrollbars_overriden_by_max_size.rs index c7491e1d9..dfadb7f15 100644 --- a/tests/generated/overflow_scrollbars_overriden_by_max_size.rs +++ b/tests/generated/overflow_scrollbars_overriden_by_max_size.rs @@ -3,34 +3,29 @@ fn overflow_scrollbars_overriden_by_max_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(4f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(4f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/overflow_scrollbars_overriden_by_size.rs b/tests/generated/overflow_scrollbars_overriden_by_size.rs index 8a4a87a76..82284b8d1 100644 --- a/tests/generated/overflow_scrollbars_overriden_by_size.rs +++ b/tests/generated/overflow_scrollbars_overriden_by_size.rs @@ -3,34 +3,29 @@ fn overflow_scrollbars_overriden_by_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(4f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(4f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width); assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/overflow_scrollbars_take_up_space_both_axis.rs b/tests/generated/overflow_scrollbars_take_up_space_both_axis.rs index 77d656b1a..d9d24f585 100644 --- a/tests/generated/overflow_scrollbars_take_up_space_both_axis.rs +++ b/tests/generated/overflow_scrollbars_take_up_space_both_axis.rs @@ -3,34 +3,29 @@ fn overflow_scrollbars_take_up_space_both_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/overflow_scrollbars_take_up_space_cross_axis.rs b/tests/generated/overflow_scrollbars_take_up_space_cross_axis.rs index 489fe1ff9..058f6c7c4 100644 --- a/tests/generated/overflow_scrollbars_take_up_space_cross_axis.rs +++ b/tests/generated/overflow_scrollbars_take_up_space_cross_axis.rs @@ -3,34 +3,29 @@ fn overflow_scrollbars_take_up_space_cross_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Visible, - y: taffy::style::Overflow::Scroll, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/overflow_scrollbars_take_up_space_main_axis.rs b/tests/generated/overflow_scrollbars_take_up_space_main_axis.rs index b8f6cda92..43eb22781 100644 --- a/tests/generated/overflow_scrollbars_take_up_space_main_axis.rs +++ b/tests/generated/overflow_scrollbars_take_up_space_main_axis.rs @@ -3,34 +3,29 @@ fn overflow_scrollbars_take_up_space_main_axis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - overflow: taffy::geometry::Point { - x: taffy::style::Overflow::Scroll, - y: taffy::style::Overflow::Visible, - }, - scrollbar_width: 15f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Visible }, + scrollbar_width: 15f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/padding_align_end_child.rs b/tests/generated/padding_align_end_child.rs index 813481041..1fa5d662a 100644 --- a/tests/generated/padding_align_end_child.rs +++ b/tests/generated/padding_align_end_child.rs @@ -3,45 +3,41 @@ fn padding_align_end_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(20f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(20f32), + bottom: taffy::style::LengthPercentage::Length(20f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::FlexEnd), + justify_content: Some(taffy::style::JustifyContent::FlexEnd), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(20f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(20f32), - bottom: taffy::style::LengthPercentage::Length(20f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::FlexEnd), - justify_content: Some(taffy::style::JustifyContent::FlexEnd), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node0, 100f32, location.x); diff --git a/tests/generated/padding_border_overrides_max_size.rs b/tests/generated/padding_border_overrides_max_size.rs index 0bb77ea9a..8b82d0518 100644 --- a/tests/generated/padding_border_overrides_max_size.rs +++ b/tests/generated/padding_border_overrides_max_size.rs @@ -3,38 +3,36 @@ fn padding_border_overrides_max_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/padding_border_overrides_min_size.rs b/tests/generated/padding_border_overrides_min_size.rs index df7d88d6c..b380ac145 100644 --- a/tests/generated/padding_border_overrides_min_size.rs +++ b/tests/generated/padding_border_overrides_min_size.rs @@ -3,38 +3,36 @@ fn padding_border_overrides_min_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(0f32), - height: taffy::style::Dimension::Length(0f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(0f32), + height: taffy::style::Dimension::Length(0f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/padding_border_overrides_size.rs b/tests/generated/padding_border_overrides_size.rs index c09efda08..a4aa2d538 100644 --- a/tests/generated/padding_border_overrides_size.rs +++ b/tests/generated/padding_border_overrides_size.rs @@ -3,38 +3,36 @@ fn padding_border_overrides_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/padding_border_overrides_size_flex_basis_0.rs b/tests/generated/padding_border_overrides_size_flex_basis_0.rs index a1a3716de..fd8c9c157 100644 --- a/tests/generated/padding_border_overrides_size_flex_basis_0.rs +++ b/tests/generated/padding_border_overrides_size_flex_basis_0.rs @@ -3,54 +3,50 @@ fn padding_border_overrides_size_flex_basis_0() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_basis: taffy::style::Dimension::Length(0f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_basis: taffy::style::Dimension::Length(0f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Length(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Length(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node, 34f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0, 22f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node1, 12f32, size.height); assert_eq!(location.x, 22f32, "x of node {:?}. Expected {}. Actual {}", node1, 22f32, location.x); diff --git a/tests/generated/padding_border_overrides_size_flex_basis_0_growable.rs b/tests/generated/padding_border_overrides_size_flex_basis_0_growable.rs index 9c5f57ef8..192b0228c 100644 --- a/tests/generated/padding_border_overrides_size_flex_basis_0_growable.rs +++ b/tests/generated/padding_border_overrides_size_flex_basis_0_growable.rs @@ -3,56 +3,52 @@ fn padding_border_overrides_size_flex_basis_0_growable() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(0f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(8f32), - right: taffy::style::LengthPercentage::Length(4f32), - top: taffy::style::LengthPercentage::Length(2f32), - bottom: taffy::style::LengthPercentage::Length(6f32), - }, - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(7f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(1f32), - bottom: taffy::style::LengthPercentage::Length(5f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(0f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(12f32), - height: taffy::style::Dimension::Length(12f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(8f32), + right: taffy::style::LengthPercentage::Length(4f32), + top: taffy::style::LengthPercentage::Length(2f32), + bottom: taffy::style::LengthPercentage::Length(6f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(7f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: taffy::style::LengthPercentage::Length(5f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(12f32), + height: taffy::style::Dimension::Length(12f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node, 34f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node0, 28f32, size.width); assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0, 14f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 6f32, "width of node {:?}. Expected {}. Actual {}", node1, 6f32, size.width); assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node1, 12f32, size.height); assert_eq!(location.x, 28f32, "x of node {:?}. Expected {}. Actual {}", node1, 28f32, location.x); diff --git a/tests/generated/padding_center_child.rs b/tests/generated/padding_center_child.rs index 18a389ae7..8128f087c 100644 --- a/tests/generated/padding_center_child.rs +++ b/tests/generated/padding_center_child.rs @@ -3,45 +3,41 @@ fn padding_center_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(20f32), - }, - ..Default::default() + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(20f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); diff --git a/tests/generated/padding_container_match_child.rs b/tests/generated/padding_container_match_child.rs index 62da5ecfa..8492c1a2f 100644 --- a/tests/generated/padding_container_match_child.rs +++ b/tests/generated/padding_container_match_child.rs @@ -3,40 +3,36 @@ fn padding_container_match_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/padding_flex_child.rs b/tests/generated/padding_flex_child.rs index 4b4ff0d6b..07ccb0fb5 100644 --- a/tests/generated/padding_flex_child.rs +++ b/tests/generated/padding_flex_child.rs @@ -3,41 +3,37 @@ fn padding_flex_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/padding_no_child.rs b/tests/generated/padding_no_child.rs index b09a5101c..411c709a9 100644 --- a/tests/generated/padding_no_child.rs +++ b/tests/generated/padding_no_child.rs @@ -3,22 +3,20 @@ fn padding_no_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), + }, + ..Default::default() + }); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/padding_no_size.rs b/tests/generated/padding_no_size.rs index e790f019c..fb33bd481 100644 --- a/tests/generated/padding_no_size.rs +++ b/tests/generated/padding_no_size.rs @@ -3,22 +3,20 @@ fn padding_no_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), + }, + ..Default::default() + }); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); diff --git a/tests/generated/padding_stretch_child.rs b/tests/generated/padding_stretch_child.rs index 7144f8e50..3ea72e535 100644 --- a/tests/generated/padding_stretch_child.rs +++ b/tests/generated/padding_stretch_child.rs @@ -3,40 +3,36 @@ fn padding_stretch_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/parent_wrap_child_size_overflowing_parent.rs b/tests/generated/parent_wrap_child_size_overflowing_parent.rs index 33be1e58f..ffa255ef6 100644 --- a/tests/generated/parent_wrap_child_size_overflowing_parent.rs +++ b/tests/generated/parent_wrap_child_size_overflowing_parent.rs @@ -3,51 +3,45 @@ fn parent_wrap_child_size_overflowing_parent() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(200f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/percent_absolute_position.rs b/tests/generated/percent_absolute_position.rs index f151b30a9..74da4e57b 100644 --- a/tests/generated/percent_absolute_position.rs +++ b/tests/generated/percent_absolute_position.rs @@ -3,70 +3,62 @@ fn percent_absolute_position() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Length(50f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.5f32), - right: auto(), - top: auto(), - bottom: auto(), - }, - ..Default::default() + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Length(50f32), }, - &[node00, node01], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(60f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.5f32), + right: auto(), + top: auto(), + bottom: auto(), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node00, node01], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(60f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node0, 30f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node00, 30f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node01, 30f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node01, 50f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node01, 30f32, location.x); diff --git a/tests/generated/percent_within_flex_grow.rs b/tests/generated/percent_within_flex_grow.rs index 83d9e2cf3..0b52990ba 100644 --- a/tests/generated/percent_within_flex_grow.rs +++ b/tests/generated/percent_within_flex_grow.rs @@ -3,71 +3,61 @@ fn percent_within_flex_grow() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - ..Default::default() + }, + &[node10], + ); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(350f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node10], - ) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(350f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 350f32, "width of node {:?}. Expected {}. Actual {}", node, 350f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node1, 150f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node10, 150f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node2, 250f32, location.x); diff --git a/tests/generated/percentage_absolute_position.rs b/tests/generated/percentage_absolute_position.rs index aa0aa429d..fc641db8c 100644 --- a/tests/generated/percentage_absolute_position.rs +++ b/tests/generated/percentage_absolute_position.rs @@ -3,45 +3,41 @@ fn percentage_absolute_position() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.3f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.3f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - bottom: auto(), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); diff --git a/tests/generated/percentage_container_in_wrapping_container.rs b/tests/generated/percentage_container_in_wrapping_container.rs index 026edf05b..c795009b7 100644 --- a/tests/generated/percentage_container_in_wrapping_container.rs +++ b/tests/generated/percentage_container_in_wrapping_container.rs @@ -3,80 +3,70 @@ fn percentage_container_in_wrapping_container() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), - }, + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node001 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(50f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node001 = taffy - .new_leaf(taffy::style::Style { + }, + &[node000, node001], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(50f32), - height: taffy::style::Dimension::Length(50f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, - ..Default::default() - }, - &[node000, node001], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); assert_eq!(location.y, 75f32, "y of node {:?}. Expected {}. Actual {}", node0, 75f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node000, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node000, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node001).unwrap(); + let Layout { size, location, .. } = taffy.layout(node001); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node001, 50f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node001, 50f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node001, 50f32, location.x); diff --git a/tests/generated/percentage_different_width_height.rs b/tests/generated/percentage_different_width_height.rs index e04c377d3..95295fcb8 100644 --- a/tests/generated/percentage_different_width_height.rs +++ b/tests/generated/percentage_different_width_height.rs @@ -3,46 +3,40 @@ fn percentage_different_width_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.3f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.3f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.3f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.3f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(300f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node0, 90f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node1, 90f32, size.height); assert_eq!(location.x, 200f32, "x of node {:?}. Expected {}. Actual {}", node1, 200f32, location.x); diff --git a/tests/generated/percentage_different_width_height_column.rs b/tests/generated/percentage_different_width_height_column.rs index dbd0f9eeb..fad792989 100644 --- a/tests/generated/percentage_different_width_height_column.rs +++ b/tests/generated/percentage_different_width_height_column.rs @@ -3,41 +3,37 @@ fn percentage_different_width_height_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.3f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(300f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.3f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(300f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 210f32, "height of node {:?}. Expected {}. Actual {}", node0, 210f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node1, 90f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/percentage_flex_basis.rs b/tests/generated/percentage_flex_basis.rs index 86ed7e628..0fdc32485 100644 --- a/tests/generated/percentage_flex_basis.rs +++ b/tests/generated/percentage_flex_basis.rs @@ -3,47 +3,41 @@ fn percentage_flex_basis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.5f32), - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.25f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.25f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 125f32, "width of node {:?}. Expected {}. Actual {}", node0, 125f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 75f32, "width of node {:?}. Expected {}. Actual {}", node1, 75f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node1, 200f32, size.height); assert_eq!(location.x, 125f32, "x of node {:?}. Expected {}. Actual {}", node1, 125f32, location.x); diff --git a/tests/generated/percentage_flex_basis_cross.rs b/tests/generated/percentage_flex_basis_cross.rs index 222b982a5..8f6693082 100644 --- a/tests/generated/percentage_flex_basis_cross.rs +++ b/tests/generated/percentage_flex_basis_cross.rs @@ -3,48 +3,42 @@ fn percentage_flex_basis_cross() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.5f32), - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.25f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(400f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.25f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(400f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 250f32, "height of node {:?}. Expected {}. Actual {}", node0, 250f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node1, 150f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/percentage_flex_basis_cross_max_height.rs b/tests/generated/percentage_flex_basis_cross_max_height.rs index 35c18b103..dc995b307 100644 --- a/tests/generated/percentage_flex_basis_cross_max_height.rs +++ b/tests/generated/percentage_flex_basis_cross_max_height.rs @@ -3,50 +3,44 @@ fn percentage_flex_basis_cross_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.6f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(400f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.6f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(400f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/percentage_flex_basis_cross_max_width.rs b/tests/generated/percentage_flex_basis_cross_max_width.rs index 9ac1171a6..3f48fc507 100644 --- a/tests/generated/percentage_flex_basis_cross_max_width.rs +++ b/tests/generated/percentage_flex_basis_cross_max_width.rs @@ -3,50 +3,44 @@ fn percentage_flex_basis_cross_max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(400f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(400f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node1, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/percentage_flex_basis_cross_min_height.rs b/tests/generated/percentage_flex_basis_cross_min_height.rs index 2746b3930..99f053bf4 100644 --- a/tests/generated/percentage_flex_basis_cross_min_height.rs +++ b/tests/generated/percentage_flex_basis_cross_min_height.rs @@ -3,48 +3,42 @@ fn percentage_flex_basis_cross_min_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.6f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 2f32, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.1f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(400f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.6f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 2f32, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.1f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(400f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node1, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/percentage_flex_basis_cross_min_width.rs b/tests/generated/percentage_flex_basis_cross_min_width.rs index 30e3a1959..ff95fb853 100644 --- a/tests/generated/percentage_flex_basis_cross_min_width.rs +++ b/tests/generated/percentage_flex_basis_cross_min_width.rs @@ -3,50 +3,44 @@ fn percentage_flex_basis_cross_min_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(400f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(400f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node1, 300f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/percentage_flex_basis_main_max_height.rs b/tests/generated/percentage_flex_basis_main_max_height.rs index 45b7d2ca8..9e5663538 100644 --- a/tests/generated/percentage_flex_basis_main_max_height.rs +++ b/tests/generated/percentage_flex_basis_main_max_height.rs @@ -3,49 +3,43 @@ fn percentage_flex_basis_main_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.6f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(400f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.6f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(400f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0, 52f32, size.width); assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 148f32, "width of node {:?}. Expected {}. Actual {}", node1, 148f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height); assert_eq!(location.x, 52f32, "x of node {:?}. Expected {}. Actual {}", node1, 52f32, location.x); diff --git a/tests/generated/percentage_flex_basis_main_max_width.rs b/tests/generated/percentage_flex_basis_main_max_width.rs index dd5a57342..fa5623409 100644 --- a/tests/generated/percentage_flex_basis_main_max_width.rs +++ b/tests/generated/percentage_flex_basis_main_max_width.rs @@ -3,49 +3,43 @@ fn percentage_flex_basis_main_max_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(400f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(400f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node0, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node1, 400f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node1, 120f32, location.x); diff --git a/tests/generated/percentage_flex_basis_main_min_width.rs b/tests/generated/percentage_flex_basis_main_min_width.rs index 0c390587a..c2aec7740 100644 --- a/tests/generated/percentage_flex_basis_main_min_width.rs +++ b/tests/generated/percentage_flex_basis_main_min_width.rs @@ -3,49 +3,43 @@ fn percentage_flex_basis_main_min_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(400f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(400f32), }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node0, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node1, 80f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node1, 400f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node1, 120f32, location.x); diff --git a/tests/generated/percentage_main_max_height.rs b/tests/generated/percentage_main_max_height.rs index 04cc31f0b..5eb3d749d 100644 --- a/tests/generated/percentage_main_max_height.rs +++ b/tests/generated/percentage_main_max_height.rs @@ -4,56 +4,49 @@ fn percentage_main_max_height() { use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Length(15f32), ..Default::default() }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { - flex_basis: taffy::style::Dimension::Length(48f32), - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.33f32) }, + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Length(15f32), ..Default::default() }); + let node01 = taffy.new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Length(48f32), + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.33f32) }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::FlexStart), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(151f32) }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::FlexStart), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(151f32) }, - ..Default::default() - }, - &[node00, node01], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(71f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00, node01], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(71f32), height: auto() }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node, 71f32, size.width); assert_eq!(size.height, 151f32, "height of node {:?}. Expected {}. Actual {}", node, 151f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node0, 71f32, size.width); assert_eq!(size.height, 151f32, "height of node {:?}. Expected {}. Actual {}", node0, 151f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node00, 15f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node01, 0f32, size.width); assert_eq!(size.height, 48f32, "height of node {:?}. Expected {}. Actual {}", node01, 48f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); diff --git a/tests/generated/percentage_margin_should_calculate_based_only_on_width.rs b/tests/generated/percentage_margin_should_calculate_based_only_on_width.rs index 2f5e7b3ef..c110ae929 100644 --- a/tests/generated/percentage_margin_should_calculate_based_only_on_width.rs +++ b/tests/generated/percentage_margin_should_calculate_based_only_on_width.rs @@ -3,59 +3,53 @@ fn percentage_margin_should_calculate_based_only_on_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.1f32), - right: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0, 160f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/percentage_moderate_complexity.rs b/tests/generated/percentage_moderate_complexity.rs index 6205a306c..e0e739089 100644 --- a/tests/generated/percentage_moderate_complexity.rs +++ b/tests/generated/percentage_moderate_complexity.rs @@ -4,15 +4,48 @@ fn percentage_moderate_complexity() { use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); taffy.disable_rounding(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(3f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(3f32), + bottom: taffy::style::LengthPercentage::Length(3f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: taffy::style::LengthPercentageAuto::Percent(0.05f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Percent(0.03f32), + right: taffy::style::LengthPercentage::Percent(0.03f32), + top: taffy::style::LengthPercentage::Percent(0.03f32), + bottom: taffy::style::LengthPercentage::Percent(0.03f32), + }, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Length(3f32), right: taffy::style::LengthPercentage::Length(3f32), @@ -20,53 +53,14 @@ fn percentage_moderate_complexity() { bottom: taffy::style::LengthPercentage::Length(3f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Percent(0.03f32), - right: taffy::style::LengthPercentage::Percent(0.03f32), - top: taffy::style::LengthPercentage::Percent(0.03f32), - bottom: taffy::style::LengthPercentage::Percent(0.03f32), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Flex, - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(3f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(3f32), - bottom: taffy::style::LengthPercentage::Length(3f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert!(size.width - 200f32 < 0.1, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert!( size.height - 42.15625f32 < 0.1, @@ -77,7 +71,7 @@ fn percentage_moderate_complexity() { ); assert!(location.x - 0f32 < 0.1, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert!(location.y - 0f32 < 0.1, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert!(size.width - 97f32 < 0.1, "width of node {:?}. Expected {}. Actual {}", node0, 97f32, size.width); assert!( size.height - 26.15625f32 < 0.1, @@ -88,12 +82,12 @@ fn percentage_moderate_complexity() { ); assert!(location.x - 8f32 < 0.1, "x of node {:?}. Expected {}. Actual {}", node0, 8f32, location.x); assert!(location.y - 8f32 < 0.1, "y of node {:?}. Expected {}. Actual {}", node0, 8f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert!( - size.width - 38.414063f32 < 0.1, + size.width - 38.40625f32 < 0.1, "width of node {:?}. Expected {}. Actual {}", node00, - 38.414063f32, + 38.40625f32, size.width ); assert!(size.height - 6f32 < 0.1, "height of node {:?}. Expected {}. Actual {}", node00, 6f32, size.height); diff --git a/tests/generated/percentage_moderate_complexity2.rs b/tests/generated/percentage_moderate_complexity2.rs index 99507f382..bce893c08 100644 --- a/tests/generated/percentage_moderate_complexity2.rs +++ b/tests/generated/percentage_moderate_complexity2.rs @@ -3,59 +3,53 @@ fn percentage_moderate_complexity2() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(20f32), + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Percent(0.1f32), + right: taffy::style::LengthPercentage::Percent(0.1f32), + top: taffy::style::LengthPercentage::Percent(0.1f32), + bottom: taffy::style::LengthPercentage::Percent(0.1f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Percent(0.1f32), - right: taffy::style::LengthPercentage::Percent(0.1f32), - top: taffy::style::LengthPercentage::Percent(0.1f32), - bottom: taffy::style::LengthPercentage::Percent(0.1f32), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); diff --git a/tests/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs b/tests/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs index 5670b4c49..a89545c00 100644 --- a/tests/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs +++ b/tests/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs @@ -3,14 +3,53 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() }, + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(3f32), + right: taffy::style::LengthPercentage::Length(3f32), + top: taffy::style::LengthPercentage::Length(3f32), + bottom: taffy::style::LengthPercentage::Length(3f32), + }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: taffy::style::LengthPercentageAuto::Percent(0.05f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Percent(0.03f32), + right: taffy::style::LengthPercentage::Percent(0.03f32), + top: taffy::style::LengthPercentage::Percent(0.03f32), + bottom: taffy::style::LengthPercentage::Percent(0.03f32), + }, + ..Default::default() + }, + &[node000], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(5f32), + right: taffy::style::LengthPercentageAuto::Length(5f32), + top: taffy::style::LengthPercentageAuto::Length(5f32), + bottom: taffy::style::LengthPercentageAuto::Length(5f32), }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Length(3f32), @@ -19,100 +58,51 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values() { bottom: taffy::style::LengthPercentage::Length(3f32), }, ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Percent(0.03f32), - right: taffy::style::LengthPercentage::Percent(0.03f32), - top: taffy::style::LengthPercentage::Percent(0.03f32), - bottom: taffy::style::LengthPercentage::Percent(0.03f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(5f32), - right: taffy::style::LengthPercentageAuto::Length(5f32), - top: taffy::style::LengthPercentageAuto::Length(5f32), - bottom: taffy::style::LengthPercentageAuto::Length(5f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(3f32), - right: taffy::style::LengthPercentage::Length(3f32), - top: taffy::style::LengthPercentage::Length(3f32), - bottom: taffy::style::LengthPercentage::Length(3f32), - }, - ..Default::default() + }, + &[node00], + ); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node00], - ) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 190f32, "width of node {:?}. Expected {}. Actual {}", node0, 190f32, size.width); assert_eq!(size.height, 48f32, "height of node {:?}. Expected {}. Actual {}", node0, 48f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 92f32, "width of node {:?}. Expected {}. Actual {}", node00, 92f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node00, 25f32, size.height); assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node00, 8f32, location.x); assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node00, 8f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node000, 36f32, size.width); assert_eq!(size.height, 6f32, "height of node {:?}. Expected {}. Actual {}", node000, 6f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node000, 10f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node000, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); assert_eq!(size.height, 142f32, "height of node {:?}. Expected {}. Actual {}", node1, 142f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/percentage_padding_should_calculate_based_only_on_width.rs b/tests/generated/percentage_padding_should_calculate_based_only_on_width.rs index dc349c6e0..238b83517 100644 --- a/tests/generated/percentage_padding_should_calculate_based_only_on_width.rs +++ b/tests/generated/percentage_padding_should_calculate_based_only_on_width.rs @@ -3,59 +3,53 @@ fn percentage_padding_should_calculate_based_only_on_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Percent(0.1f32), + right: taffy::style::LengthPercentage::Percent(0.1f32), + top: taffy::style::LengthPercentage::Percent(0.1f32), + bottom: taffy::style::LengthPercentage::Percent(0.1f32), }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Percent(0.1f32), - right: taffy::style::LengthPercentage::Percent(0.1f32), - top: taffy::style::LengthPercentage::Percent(0.1f32), - bottom: taffy::style::LengthPercentage::Percent(0.1f32), - }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x); diff --git a/tests/generated/percentage_position_bottom_right.rs b/tests/generated/percentage_position_bottom_right.rs index a9d03ce90..3ca99a245 100644 --- a/tests/generated/percentage_position_bottom_right.rs +++ b/tests/generated/percentage_position_bottom_right.rs @@ -3,43 +3,39 @@ fn percentage_position_bottom_right() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.55f32), + height: taffy::style::Dimension::Percent(0.15f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Percent(0.2f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.55f32), - height: taffy::style::Dimension::Percent(0.15f32), - }, - inset: taffy::geometry::Rect { - left: auto(), - right: taffy::style::LengthPercentageAuto::Percent(0.2f32), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + width: taffy::style::Dimension::Length(500f32), + height: taffy::style::Dimension::Length(500f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(500f32), - height: taffy::style::Dimension::Length(500f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 275f32, "width of node {:?}. Expected {}. Actual {}", node0, 275f32, size.width); assert_eq!(size.height, 75f32, "height of node {:?}. Expected {}. Actual {}", node0, 75f32, size.height); assert_eq!(location.x, -100f32, "x of node {:?}. Expected {}. Actual {}", node0, -100f32, location.x); diff --git a/tests/generated/percentage_position_left_top.rs b/tests/generated/percentage_position_left_top.rs index 7349ff755..5fc8e8f89 100644 --- a/tests/generated/percentage_position_left_top.rs +++ b/tests/generated/percentage_position_left_top.rs @@ -3,43 +3,39 @@ fn percentage_position_left_top() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.45f32), + height: taffy::style::Dimension::Percent(0.55f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.2f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.45f32), - height: taffy::style::Dimension::Percent(0.55f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.1f32), - right: auto(), - top: taffy::style::LengthPercentageAuto::Percent(0.2f32), - bottom: auto(), + width: taffy::style::Dimension::Length(400f32), + height: taffy::style::Dimension::Length(400f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(400f32), - height: taffy::style::Dimension::Length(400f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width); assert_eq!(size.height, 220f32, "height of node {:?}. Expected {}. Actual {}", node0, 220f32, size.height); assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x); diff --git a/tests/generated/percentage_size_based_on_parent_inner_size.rs b/tests/generated/percentage_size_based_on_parent_inner_size.rs index f303ae2ef..e4d510c05 100644 --- a/tests/generated/percentage_size_based_on_parent_inner_size.rs +++ b/tests/generated/percentage_size_based_on_parent_inner_size.rs @@ -3,44 +3,40 @@ fn percentage_size_based_on_parent_inner_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.5f32), + height: taffy::style::Dimension::Percent(0.5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.5f32), - height: taffy::style::Dimension::Percent(0.5f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(400f32), }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(400f32), - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(20f32), - right: taffy::style::LengthPercentage::Length(20f32), - top: taffy::style::LengthPercentage::Length(20f32), - bottom: taffy::style::LengthPercentage::Length(20f32), - }, - ..Default::default() + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(20f32), + right: taffy::style::LengthPercentage::Length(20f32), + top: taffy::style::LengthPercentage::Length(20f32), + bottom: taffy::style::LengthPercentage::Length(20f32), }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node0, 180f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); diff --git a/tests/generated/percentage_size_of_flex_basis.rs b/tests/generated/percentage_size_of_flex_basis.rs index 36c0279b9..00e4be8cc 100644 --- a/tests/generated/percentage_size_of_flex_basis.rs +++ b/tests/generated/percentage_size_of_flex_basis.rs @@ -3,45 +3,39 @@ fn percentage_size_of_flex_basis() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { flex_basis: taffy::style::Dimension::Length(50f32), ..Default::default() }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { flex_basis: taffy::style::Dimension::Length(50f32), ..Default::default() }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/percentage_sizes_should_not_prevent_flex_shrinking.rs b/tests/generated/percentage_sizes_should_not_prevent_flex_shrinking.rs index ab05d9ef6..62dcc9119 100644 --- a/tests/generated/percentage_sizes_should_not_prevent_flex_shrinking.rs +++ b/tests/generated/percentage_sizes_should_not_prevent_flex_shrinking.rs @@ -3,43 +3,39 @@ fn percentage_sizes_should_not_prevent_flex_shrinking() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1.2f32), height: auto() }, - ..Default::default() + let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }); + let node0 = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1.2f32), height: auto() }, + ..Default::default() + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/percentage_width_height.rs b/tests/generated/percentage_width_height.rs index 92e2d3879..8f557e2d0 100644 --- a/tests/generated/percentage_width_height.rs +++ b/tests/generated/percentage_width_height.rs @@ -3,37 +3,33 @@ fn percentage_width_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.3f32), + height: taffy::style::Dimension::Percent(0.3f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.3f32), - height: taffy::style::Dimension::Percent(0.3f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(400f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(400f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node, 400f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/percentage_width_height_undefined_parent_size.rs b/tests/generated/percentage_width_height_undefined_parent_size.rs index 837f5a3f0..9cd1f317c 100644 --- a/tests/generated/percentage_width_height_undefined_parent_size.rs +++ b/tests/generated/percentage_width_height_undefined_parent_size.rs @@ -3,31 +3,27 @@ fn percentage_width_height_undefined_parent_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.5f32), - height: taffy::style::Dimension::Percent(0.5f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.5f32), + height: taffy::style::Dimension::Percent(0.5f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/position_root_with_rtl_should_position_withoutdirection.rs b/tests/generated/position_root_with_rtl_should_position_withoutdirection.rs index c5d957eea..84ff41105 100644 --- a/tests/generated/position_root_with_rtl_should_position_withoutdirection.rs +++ b/tests/generated/position_root_with_rtl_should_position_withoutdirection.rs @@ -3,32 +3,30 @@ fn position_root_with_rtl_should_position_withoutdirection() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(52f32), - height: taffy::style::Dimension::Length(52f32), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(72f32), - right: auto(), - top: auto(), - bottom: auto(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(52f32), + height: taffy::style::Dimension::Length(52f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(72f32), + right: auto(), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node, 52f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node0, 52f32, size.width); assert_eq!(size.height, 52f32, "height of node {:?}. Expected {}. Actual {}", node0, 52f32, size.height); assert_eq!(location.x, 72f32, "x of node {:?}. Expected {}. Actual {}", node0, 72f32, location.x); diff --git a/tests/generated/relative_position_should_not_nudge_siblings.rs b/tests/generated/relative_position_should_not_nudge_siblings.rs index c0cfe1095..6e0a691d1 100644 --- a/tests/generated/relative_position_should_not_nudge_siblings.rs +++ b/tests/generated/relative_position_should_not_nudge_siblings.rs @@ -3,58 +3,52 @@ fn relative_position_should_not_nudge_siblings() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(15f32), - bottom: auto(), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(15f32), + bottom: auto(), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(15f32), + bottom: auto(), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(15f32), - bottom: auto(), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0, 15f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); diff --git a/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs b/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs index 4e6056643..841cbe0d9 100644 --- a/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs +++ b/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs @@ -3,53 +3,51 @@ fn rounding_flex_basis_flex_grow_row_prime_number_width() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node3 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node4 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(113f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node3 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node4 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(113f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 113f32, "width of node {:?}. Expected {}. Actual {}", node, 113f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 23f32, "width of node {:?}. Expected {}. Actual {}", node0, 23f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node1, 22f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 23f32, "x of node {:?}. Expected {}. Actual {}", node1, 23f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 23f32, "width of node {:?}. Expected {}. Actual {}", node2, 23f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node2, 45f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node3, 22f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height); assert_eq!(location.x, 68f32, "x of node {:?}. Expected {}. Actual {}", node3, 68f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 23f32, "width of node {:?}. Expected {}. Actual {}", node4, 23f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node4, 100f32, size.height); assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node4, 90f32, location.x); diff --git a/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs b/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs index ee9a28c81..786462641 100644 --- a/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs +++ b/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs @@ -3,41 +3,39 @@ fn rounding_flex_basis_flex_grow_row_width_of_100() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node2 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node0, 33f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node1, 34f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 33f32, "x of node {:?}. Expected {}. Actual {}", node1, 33f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node2, 33f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node2, 67f32, location.x); diff --git a/tests/generated/rounding_flex_basis_flex_shrink_row.rs b/tests/generated/rounding_flex_basis_flex_shrink_row.rs index bc5b58634..9f8b963fc 100644 --- a/tests/generated/rounding_flex_basis_flex_shrink_row.rs +++ b/tests/generated/rounding_flex_basis_flex_shrink_row.rs @@ -3,51 +3,45 @@ fn rounding_flex_basis_flex_shrink_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Length(100f32), - ..Default::default() - }) - .unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Length(100f32), + ..Default::default() + }); let node1 = taffy - .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Length(25f32), ..Default::default() }) - .unwrap(); + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Length(25f32), ..Default::default() }); let node2 = taffy - .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Length(25f32), ..Default::default() }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(101f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Length(25f32), ..Default::default() }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(101f32), + height: taffy::style::Dimension::Length(100f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 101f32, "width of node {:?}. Expected {}. Actual {}", node, 101f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 67f32, "width of node {:?}. Expected {}. Actual {}", node0, 67f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node1, 17f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node1, 67f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node2, 17f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 84f32, "x of node {:?}. Expected {}. Actual {}", node2, 84f32, location.x); diff --git a/tests/generated/rounding_flex_basis_overrides_main_size.rs b/tests/generated/rounding_flex_basis_overrides_main_size.rs index 3e0af8e7b..9193955a6 100644 --- a/tests/generated/rounding_flex_basis_overrides_main_size.rs +++ b/tests/generated/rounding_flex_basis_overrides_main_size.rs @@ -3,61 +3,53 @@ fn rounding_flex_basis_overrides_main_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(50f32), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(113f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(113f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 64f32, "height of node {:?}. Expected {}. Actual {}", node0, 64f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1, 64f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/rounding_fractial_input_1.rs b/tests/generated/rounding_fractial_input_1.rs index b04814083..b5ee0ce22 100644 --- a/tests/generated/rounding_fractial_input_1.rs +++ b/tests/generated/rounding_fractial_input_1.rs @@ -3,61 +3,53 @@ fn rounding_fractial_input_1() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(50f32), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(113.4f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(113.4f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 64f32, "height of node {:?}. Expected {}. Actual {}", node0, 64f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1, 64f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/rounding_fractial_input_2.rs b/tests/generated/rounding_fractial_input_2.rs index f21429ce3..e2487b866 100644 --- a/tests/generated/rounding_fractial_input_2.rs +++ b/tests/generated/rounding_fractial_input_2.rs @@ -3,61 +3,53 @@ fn rounding_fractial_input_2() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(50f32), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(113.6f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(113.6f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 114f32, "height of node {:?}. Expected {}. Actual {}", node, 114f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 65f32, "height of node {:?}. Expected {}. Actual {}", node0, 65f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node1, 24f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node2, 25f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/rounding_fractial_input_3.rs b/tests/generated/rounding_fractial_input_3.rs index 9acb9fc46..1965d245c 100644 --- a/tests/generated/rounding_fractial_input_3.rs +++ b/tests/generated/rounding_fractial_input_3.rs @@ -3,61 +3,53 @@ fn rounding_fractial_input_3() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(50f32), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(113.4f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(113.4f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 64f32, "height of node {:?}. Expected {}. Actual {}", node0, 64f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1, 64f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/rounding_fractial_input_4.rs b/tests/generated/rounding_fractial_input_4.rs index e3e11cc46..5b79a5754 100644 --- a/tests/generated/rounding_fractial_input_4.rs +++ b/tests/generated/rounding_fractial_input_4.rs @@ -3,61 +3,53 @@ fn rounding_fractial_input_4() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(50f32), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(113.4f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(113.4f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 64f32, "height of node {:?}. Expected {}. Actual {}", node0, 64f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1, 64f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/rounding_fractial_input_5.rs b/tests/generated/rounding_fractial_input_5.rs index e118464ea..f8b6fe956 100644 --- a/tests/generated/rounding_fractial_input_5.rs +++ b/tests/generated/rounding_fractial_input_5.rs @@ -3,52 +3,46 @@ fn rounding_fractial_input_5() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100.3f32), + height: taffy::style::Dimension::Length(100.3f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100.3f32), + height: taffy::style::Dimension::Length(100.3f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100.3f32), - height: taffy::style::Dimension::Length(100.3f32), + width: taffy::style::Dimension::Length(963.333f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100.3f32), - height: taffy::style::Dimension::Length(100.3f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(963.333f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 963f32, "width of node {:?}. Expected {}. Actual {}", node, 963f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 101f32, "width of node {:?}. Expected {}. Actual {}", node0, 101f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 381f32, "x of node {:?}. Expected {}. Actual {}", node0, 381f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 482f32, "x of node {:?}. Expected {}. Actual {}", node1, 482f32, location.x); diff --git a/tests/generated/rounding_fractial_input_6.rs b/tests/generated/rounding_fractial_input_6.rs index c90401478..7fe5741ef 100644 --- a/tests/generated/rounding_fractial_input_6.rs +++ b/tests/generated/rounding_fractial_input_6.rs @@ -3,106 +3,92 @@ fn rounding_fractial_input_6() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(10f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(10f32), - }, + }, + &[node00, node01], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node11 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(2f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, - ..Default::default() - }, - &[node00, node01], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(10f32), - }, + }, + &[node10, node11], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(7f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node11 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(2f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, - ..Default::default() - }, - &[node10, node11], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(7f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 7f32, "width of node {:?}. Expected {}. Actual {}", node, 7f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 4f32, "width of node {:?}. Expected {}. Actual {}", node0, 4f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node00, 2f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node01, 2f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node01, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 3f32, "width of node {:?}. Expected {}. Actual {}", node1, 3f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node1, 4f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node10, 2f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node11, 2f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); diff --git a/tests/generated/rounding_fractial_input_7.rs b/tests/generated/rounding_fractial_input_7.rs index 4b3140d5b..ff2f8af47 100644 --- a/tests/generated/rounding_fractial_input_7.rs +++ b/tests/generated/rounding_fractial_input_7.rs @@ -3,192 +3,166 @@ fn rounding_fractial_input_7() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(1f32), - height: taffy::style::Dimension::Length(10f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(1f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(1f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.25f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(1f32), - height: taffy::style::Dimension::Length(10f32), - }, + }, + &[node00, node01], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(1f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node11 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(1f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.25f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.25f32), height: auto() }, - ..Default::default() - }, - &[node00, node01], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(1f32), - height: taffy::style::Dimension::Length(10f32), - }, + }, + &[node10, node11], + ); + let node20 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(1f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node21 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(1f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node2 = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.25f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node11 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(1f32), - height: taffy::style::Dimension::Length(10f32), - }, + }, + &[node20, node21], + ); + let node30 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(1f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node31 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(1f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node3 = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.25f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.25f32), height: auto() }, - ..Default::default() - }, - &[node10, node11], - ) - .unwrap(); - let node20 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(1f32), - height: taffy::style::Dimension::Length(10f32), - }, + }, + &[node30, node31], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(7f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node21 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(1f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.25f32), height: auto() }, - ..Default::default() - }, - &[node20, node21], - ) - .unwrap(); - let node30 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(1f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node31 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(1f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.25f32), height: auto() }, - ..Default::default() - }, - &[node30, node31], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(7f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 7f32, "width of node {:?}. Expected {}. Actual {}", node, 7f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node00, 1f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node01, 1f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node01, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node1, 2f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node1, 2f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node10, 1f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node11, 1f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node11, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node2, 1f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node2, 4f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node20).unwrap(); + let Layout { size, location, .. } = taffy.layout(node20); assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node20, 1f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node21).unwrap(); + let Layout { size, location, .. } = taffy.layout(node21); assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node21, 1f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node21, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node21, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node21, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node3, 2f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node3, 5f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node30).unwrap(); + let Layout { size, location, .. } = taffy.layout(node30); assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node30, 1f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node30, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node30, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node30, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node31).unwrap(); + let Layout { size, location, .. } = taffy.layout(node31); assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node31, 1f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node31, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node31, 0f32, location.x); diff --git a/tests/generated/rounding_inner_node_controversy_combined.rs b/tests/generated/rounding_inner_node_controversy_combined.rs index 6be097017..64aa2f5c9 100644 --- a/tests/generated/rounding_inner_node_controversy_combined.rs +++ b/tests/generated/rounding_inner_node_controversy_combined.rs @@ -3,115 +3,99 @@ fn rounding_inner_node_controversy_combined() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) }, - ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node110 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, + ..Default::default() + }); + let node110 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, + ..Default::default() + }); + let node11 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node11 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, - ..Default::default() - }, - &[node110], - ) - .unwrap(); - let node12 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) }, - ..Default::default() - }, - &[node10, node11, node12], - ) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { + }, + &[node110], + ); + let node12 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(640f32), - height: taffy::style::Dimension::Length(320f32), - }, - ..Default::default() + }, + &[node10, node11, node12], + ); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(640f32), + height: taffy::style::Dimension::Length(320f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 640f32, "width of node {:?}. Expected {}. Actual {}", node, 640f32, size.width); assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 213f32, "width of node {:?}. Expected {}. Actual {}", node0, 213f32, size.width); assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node0, 320f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node1, 214f32, size.width); assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node1, 320f32, size.height); assert_eq!(location.x, 213f32, "x of node {:?}. Expected {}. Actual {}", node1, 213f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node10, 214f32, size.width); assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node10, 107f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node11).unwrap(); + let Layout { size, location, .. } = taffy.layout(node11); assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node11, 214f32, size.width); assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node11, 106f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x); assert_eq!(location.y, 107f32, "y of node {:?}. Expected {}. Actual {}", node11, 107f32, location.y); - let Layout { size, location, .. } = taffy.layout(node110).unwrap(); + let Layout { size, location, .. } = taffy.layout(node110); assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node110, 214f32, size.width); assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node110, 106f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node110, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node110, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node12).unwrap(); + let Layout { size, location, .. } = taffy.layout(node12); assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node12, 214f32, size.width); assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node12, 107f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x); assert_eq!(location.y, 213f32, "y of node {:?}. Expected {}. Actual {}", node12, 213f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 213f32, "width of node {:?}. Expected {}. Actual {}", node2, 213f32, size.width); assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node2, 320f32, size.height); assert_eq!(location.x, 427f32, "x of node {:?}. Expected {}. Actual {}", node2, 427f32, location.x); diff --git a/tests/generated/rounding_inner_node_controversy_horizontal.rs b/tests/generated/rounding_inner_node_controversy_horizontal.rs index e9c2dda06..136778db5 100644 --- a/tests/generated/rounding_inner_node_controversy_horizontal.rs +++ b/tests/generated/rounding_inner_node_controversy_horizontal.rs @@ -3,72 +3,62 @@ fn rounding_inner_node_controversy_horizontal() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + }, + &[node10], + ); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(320f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(320f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 107f32, "width of node {:?}. Expected {}. Actual {}", node0, 107f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 106f32, "width of node {:?}. Expected {}. Actual {}", node1, 106f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height); assert_eq!(location.x, 107f32, "x of node {:?}. Expected {}. Actual {}", node1, 107f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 106f32, "width of node {:?}. Expected {}. Actual {}", node10, 106f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 107f32, "width of node {:?}. Expected {}. Actual {}", node2, 107f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); assert_eq!(location.x, 213f32, "x of node {:?}. Expected {}. Actual {}", node2, 213f32, location.x); diff --git a/tests/generated/rounding_inner_node_controversy_vertical.rs b/tests/generated/rounding_inner_node_controversy_vertical.rs index 518de5174..026138c43 100644 --- a/tests/generated/rounding_inner_node_controversy_vertical.rs +++ b/tests/generated/rounding_inner_node_controversy_vertical.rs @@ -3,73 +3,63 @@ fn rounding_inner_node_controversy_vertical() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node10 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + }, + &[node10], + ); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(320f32) }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(320f32) }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0, 107f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width); assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node1, 106f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 107f32, "y of node {:?}. Expected {}. Actual {}", node1, 107f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width); assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node10, 106f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width); assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node2, 107f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/rounding_total_fractial.rs b/tests/generated/rounding_total_fractial.rs index a7d299cbf..032b37493 100644 --- a/tests/generated/rounding_total_fractial.rs +++ b/tests/generated/rounding_total_fractial.rs @@ -3,61 +3,53 @@ fn rounding_total_fractial() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 0.7f32, - flex_basis: taffy::style::Dimension::Length(50.3f32), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20.3f32) }, - ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1.6f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1.1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10.7f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(87.4f32), - height: taffy::style::Dimension::Length(113.4f32), - }, - ..Default::default() + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 0.7f32, + flex_basis: taffy::style::Dimension::Length(50.3f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20.3f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1.6f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1.1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10.7f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(87.4f32), + height: taffy::style::Dimension::Length(113.4f32), }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + ..Default::default() + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node, 87f32, size.width); assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node0, 87f32, size.width); assert_eq!(size.height, 59f32, "height of node {:?}. Expected {}. Actual {}", node0, 59f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node1, 87f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 59f32, "y of node {:?}. Expected {}. Actual {}", node1, 59f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node2, 87f32, size.width); assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/rounding_total_fractial_nested.rs b/tests/generated/rounding_total_fractial_nested.rs index 027195c93..d37a18425 100644 --- a/tests/generated/rounding_total_fractial_nested.rs +++ b/tests/generated/rounding_total_fractial_nested.rs @@ -3,103 +3,91 @@ fn rounding_total_fractial_nested() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Length(0.3f32), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(9.9f32) }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: auto(), - bottom: taffy::style::LengthPercentageAuto::Length(13.3f32), - }, - ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Length(0.3f32), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(1.1f32) }, - inset: taffy::geometry::Rect { - left: auto(), - right: auto(), - top: taffy::style::LengthPercentageAuto::Length(13.3f32), - bottom: auto(), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Length(0.3f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(9.9f32) }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Length(13.3f32), + }, + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Length(0.3f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(1.1f32) }, + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Length(13.3f32), + bottom: auto(), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 0.7f32, + flex_basis: taffy::style::Dimension::Length(50.3f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20.3f32) }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 0.7f32, - flex_basis: taffy::style::Dimension::Length(50.3f32), - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(20.3f32) }, - ..Default::default() + }, + &[node00, node01], + ); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1.6f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1.1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10.7f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(87.4f32), + height: taffy::style::Dimension::Length(113.4f32), }, - &[node00, node01], - ) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1.6f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1.1f32, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10.7f32) }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(87.4f32), - height: taffy::style::Dimension::Length(113.4f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node, 87f32, size.width); assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node, 113f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node0, 87f32, size.width); assert_eq!(size.height, 59f32, "height of node {:?}. Expected {}. Actual {}", node0, 59f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node00, 87f32, size.width); assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node00, 12f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, -13f32, "y of node {:?}. Expected {}. Actual {}", node00, -13f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node01, 87f32, size.width); assert_eq!(size.height, 47f32, "height of node {:?}. Expected {}. Actual {}", node01, 47f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node01, 25f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node1, 87f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 59f32, "y of node {:?}. Expected {}. Actual {}", node1, 59f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 87f32, "width of node {:?}. Expected {}. Actual {}", node2, 87f32, size.width); assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2, 24f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/simple_child.rs b/tests/generated/simple_child.rs index a27a91c8a..910f8b70d 100644 --- a/tests/generated/simple_child.rs +++ b/tests/generated/simple_child.rs @@ -3,107 +3,95 @@ fn simple_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: taffy::style::Dimension::Length(10f32), }, ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), - }, - ..Default::default() - }, - &[node000], - ) - .unwrap(); - let node010 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Center), + }, + &[node000], + ); + let node010 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node011 = taffy.new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node01 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node010, node011]); + let node0 = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Percent(1f32), }, ..Default::default() - }) - .unwrap(); - let node011 = taffy - .new_leaf(taffy::style::Style { - align_self: Some(taffy::style::AlignSelf::Center), + }, + &[node00, node01], + ); + let node = taffy.new_with_children( + taffy::style::Style { size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node01 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node010, node011]).unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Percent(1f32), - }, - ..Default::default() - }, - &[node00, node01], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node000, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node01, 100f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node010).unwrap(); + let Layout { size, location, .. } = taffy.layout(node010); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node010, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node010, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node010, 0f32, location.x); assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node010, 45f32, location.y); - let Layout { size, location, .. } = taffy.layout(node011).unwrap(); + let Layout { size, location, .. } = taffy.layout(node011); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node011, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node011, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node011, 10f32, location.x); diff --git a/tests/generated/single_flex_child_after_absolute_child.rs b/tests/generated/single_flex_child_after_absolute_child.rs index 10193a5ac..5a0d8a0ab 100644 --- a/tests/generated/single_flex_child_after_absolute_child.rs +++ b/tests/generated/single_flex_child_after_absolute_child.rs @@ -3,58 +3,51 @@ fn single_flex_child_after_absolute_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - position: taffy::style::Position::Absolute, + let node0 = taffy.new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Percent(1f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }); + let node2 = taffy.new_leaf(taffy::style::Style { + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Length(174f32), + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Percent(1f32), + width: taffy::style::Dimension::Length(428f32), + height: taffy::style::Dimension::Length(845f32), }, ..Default::default() - }) - .unwrap(); - let node1 = - taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Length(174f32), - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(428f32), - height: taffy::style::Dimension::Length(845f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 428f32, "width of node {:?}. Expected {}. Actual {}", node, 428f32, size.width); assert_eq!(size.height, 845f32, "height of node {:?}. Expected {}. Actual {}", node, 845f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 428f32, "width of node {:?}. Expected {}. Actual {}", node0, 428f32, size.width); assert_eq!(size.height, 845f32, "height of node {:?}. Expected {}. Actual {}", node0, 845f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 428f32, "width of node {:?}. Expected {}. Actual {}", node1, 428f32, size.width); assert_eq!(size.height, 671f32, "height of node {:?}. Expected {}. Actual {}", node1, 671f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 428f32, "width of node {:?}. Expected {}. Actual {}", node2, 428f32, size.width); assert_eq!(size.height, 174f32, "height of node {:?}. Expected {}. Actual {}", node2, 174f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); diff --git a/tests/generated/size_defined_by_child.rs b/tests/generated/size_defined_by_child.rs index 5113f358a..be7f39da7 100644 --- a/tests/generated/size_defined_by_child.rs +++ b/tests/generated/size_defined_by_child.rs @@ -3,26 +3,24 @@ fn size_defined_by_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/size_defined_by_child_with_border.rs b/tests/generated/size_defined_by_child_with_border.rs index 4f978bb9e..063809a84 100644 --- a/tests/generated/size_defined_by_child_with_border.rs +++ b/tests/generated/size_defined_by_child_with_border.rs @@ -3,39 +3,35 @@ fn size_defined_by_child_with_border() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/size_defined_by_child_with_padding.rs b/tests/generated/size_defined_by_child_with_padding.rs index b1dbc55a0..3777cb60b 100644 --- a/tests/generated/size_defined_by_child_with_padding.rs +++ b/tests/generated/size_defined_by_child_with_padding.rs @@ -3,39 +3,35 @@ fn size_defined_by_child_with_padding() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(10f32), - height: taffy::style::Dimension::Length(10f32), + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(10f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Length(10f32), + right: taffy::style::LengthPercentage::Length(10f32), + top: taffy::style::LengthPercentage::Length(10f32), + bottom: taffy::style::LengthPercentage::Length(10f32), }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Length(10f32), - right: taffy::style::LengthPercentage::Length(10f32), - top: taffy::style::LengthPercentage::Length(10f32), - bottom: taffy::style::LengthPercentage::Length(10f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x); diff --git a/tests/generated/size_defined_by_grand_child.rs b/tests/generated/size_defined_by_grand_child.rs index 7ef97dfbb..6d450c19a 100644 --- a/tests/generated/size_defined_by_grand_child.rs +++ b/tests/generated/size_defined_by_grand_child.rs @@ -3,32 +3,30 @@ fn size_defined_by_grand_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/undefined_height_with_min_max.rs b/tests/generated/undefined_height_with_min_max.rs index bd535d40b..d5e951cdf 100644 --- a/tests/generated/undefined_height_with_min_max.rs +++ b/tests/generated/undefined_height_with_min_max.rs @@ -3,34 +3,30 @@ fn undefined_height_with_min_max() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(0f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(320f32), height: auto() }, min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(0f32) }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(320f32), height: auto() }, - min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(0f32) }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/undefined_width_with_min_max.rs b/tests/generated/undefined_width_with_min_max.rs index d513e0918..08fb0e2f8 100644 --- a/tests/generated/undefined_width_with_min_max.rs +++ b/tests/generated/undefined_width_with_min_max.rs @@ -3,33 +3,29 @@ fn undefined_width_with_min_max() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + let node0 = taffy.new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/undefined_width_with_min_max_row.rs b/tests/generated/undefined_width_with_min_max_row.rs index cef3d9d4b..769d4fd8d 100644 --- a/tests/generated/undefined_width_with_min_max_row.rs +++ b/tests/generated/undefined_width_with_min_max_row.rs @@ -3,49 +3,43 @@ fn undefined_width_with_min_max_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(20f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(300f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(300f32), height: auto() }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node00], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) }, + ..Default::default() + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node00, 30f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/width_smaller_then_content_with_flex_grow_large_size.rs b/tests/generated/width_smaller_then_content_with_flex_grow_large_size.rs index c3004f96b..2d7d8c86e 100644 --- a/tests/generated/width_smaller_then_content_with_flex_grow_large_size.rs +++ b/tests/generated/width_smaller_then_content_with_flex_grow_large_size.rs @@ -3,80 +3,70 @@ fn width_smaller_then_content_with_flex_grow_large_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(70f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(70f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(100f32), - }, + }, + &[node00], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/width_smaller_then_content_with_flex_grow_small_size.rs b/tests/generated/width_smaller_then_content_with_flex_grow_small_size.rs index 3960dcb80..b750df6bb 100644 --- a/tests/generated/width_smaller_then_content_with_flex_grow_small_size.rs +++ b/tests/generated/width_smaller_then_content_with_flex_grow_small_size.rs @@ -3,80 +3,70 @@ fn width_smaller_then_content_with_flex_grow_small_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(70f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(70f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(100f32), - }, + }, + &[node00], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() }, + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 5f32, "width of node {:?}. Expected {}. Actual {}", node0, 5f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 5f32, "width of node {:?}. Expected {}. Actual {}", node1, 5f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node1, 5f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs b/tests/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs index 858f5edb9..da856de98 100644 --- a/tests/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs +++ b/tests/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs @@ -3,72 +3,64 @@ fn width_smaller_then_content_with_flex_grow_unconstraint_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(70f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(70f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(100f32), - }, + }, + &[node00], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node10], + ); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs b/tests/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs index e1c276ded..dfc47d39b 100644 --- a/tests/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs +++ b/tests/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs @@ -3,80 +3,70 @@ fn width_smaller_then_content_with_flex_grow_very_large_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(70f32), - height: taffy::style::Dimension::Length(100f32), - }, + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(70f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, - ..Default::default() - }, - &[node00], - ) - .unwrap(); - let node10 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(20f32), - height: taffy::style::Dimension::Length(100f32), - }, + }, + &[node00], + ); + let node10 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(20f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node1 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() }, - ..Default::default() - }, - &[node10], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, - ..Default::default() - }, - &[node0, node1], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node10], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() }, + ..Default::default() + }, + &[node0, node1], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node00, 70f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height); assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + let Layout { size, location, .. } = taffy.layout(node10); assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node10, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); diff --git a/tests/generated/wrap_child.rs b/tests/generated/wrap_child.rs index 6e80abd1b..9d5da5667 100644 --- a/tests/generated/wrap_child.rs +++ b/tests/generated/wrap_child.rs @@ -3,31 +3,27 @@ fn wrap_child() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); diff --git a/tests/generated/wrap_column.rs b/tests/generated/wrap_column.rs index 558d30351..6c2ac2a50 100644 --- a/tests/generated/wrap_column.rs +++ b/tests/generated/wrap_column.rs @@ -3,81 +3,71 @@ fn wrap_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(31f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(32f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(33f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(34f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(31f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(32f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(33f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(34f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node0, 31f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 32f32, "height of node {:?}. Expected {}. Actual {}", node1, 32f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node1, 31f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node2, 33f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); assert_eq!(location.y, 63f32, "y of node {:?}. Expected {}. Actual {}", node2, 63f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); assert_eq!(size.height, 34f32, "height of node {:?}. Expected {}. Actual {}", node3, 34f32, size.height); assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x); diff --git a/tests/generated/wrap_grandchild.rs b/tests/generated/wrap_grandchild.rs index 34879eee9..5fab314bf 100644 --- a/tests/generated/wrap_grandchild.rs +++ b/tests/generated/wrap_grandchild.rs @@ -3,32 +3,30 @@ fn wrap_grandchild() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); - let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]); + let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); diff --git a/tests/generated/wrap_nodes_with_content_sizing_margin_cross.rs b/tests/generated/wrap_nodes_with_content_sizing_margin_cross.rs index e626b5b3d..2ddb181d0 100644 --- a/tests/generated/wrap_nodes_with_content_sizing_margin_cross.rs +++ b/tests/generated/wrap_nodes_with_content_sizing_margin_cross.rs @@ -3,98 +3,86 @@ fn wrap_nodes_with_content_sizing_margin_cross() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(40f32), + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node000], + ); + let node010 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node01 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), }, ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - &[node000], - ) - .unwrap(); - let node010 = taffy - .new_leaf(taffy::style::Style { + }, + &[node010], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(70f32), height: auto() }, + ..Default::default() + }, + &[node00, node01], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(40f32), + width: taffy::style::Dimension::Length(500f32), + height: taffy::style::Dimension::Length(500f32), }, ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - margin: taffy::geometry::Rect { - left: zero(), - right: zero(), - top: taffy::style::LengthPercentageAuto::Length(10f32), - bottom: zero(), - }, - ..Default::default() - }, - &[node010], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(70f32), height: auto() }, - ..Default::default() - }, - &[node00, node01], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(500f32), - height: taffy::style::Dimension::Length(500f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 70f32, "width of node {:?}. Expected {}. Actual {}", node0, 70f32, size.width); assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node0, 90f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node000, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node000, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node01, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node010).unwrap(); + let Layout { size, location, .. } = taffy.layout(node010); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node010, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node010, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node010, 0f32, location.x); diff --git a/tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs b/tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs index 41b59df93..4ffaa3820 100644 --- a/tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs +++ b/tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs @@ -3,98 +3,86 @@ fn wrap_nodes_with_content_sizing_overflowing_margin() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(40f32), + let node000 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node00 = taffy.new_with_children( + taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node000], + ); + let node010 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node01 = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Length(10f32), + top: zero(), + bottom: zero(), }, ..Default::default() - }) - .unwrap(); - let node00 = taffy - .new_with_children( - taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, - &[node000], - ) - .unwrap(); - let node010 = taffy - .new_leaf(taffy::style::Style { + }, + &[node010], + ); + let node0 = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(85f32), height: auto() }, + ..Default::default() + }, + &[node00, node01], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(40f32), - height: taffy::style::Dimension::Length(40f32), + width: taffy::style::Dimension::Length(500f32), + height: taffy::style::Dimension::Length(500f32), }, ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - margin: taffy::geometry::Rect { - left: zero(), - right: taffy::style::LengthPercentageAuto::Length(10f32), - top: zero(), - bottom: zero(), - }, - ..Default::default() - }, - &[node010], - ) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(85f32), height: auto() }, - ..Default::default() - }, - &[node00, node01], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(500f32), - height: taffy::style::Dimension::Length(500f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 85f32, "width of node {:?}. Expected {}. Actual {}", node0, 85f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node000).unwrap(); + let Layout { size, location, .. } = taffy.layout(node000); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node000, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node000, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node01, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node010).unwrap(); + let Layout { size, location, .. } = taffy.layout(node010); assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node010, 40f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node010, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node010, 0f32, location.x); diff --git a/tests/generated/wrap_reverse_column.rs b/tests/generated/wrap_reverse_column.rs index 73ef17489..4043705b2 100644 --- a/tests/generated/wrap_reverse_column.rs +++ b/tests/generated/wrap_reverse_column.rs @@ -3,81 +3,71 @@ fn wrap_reverse_column() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(31f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(32f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(33f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(34f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::WrapReverse, size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(31f32), + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(32f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(33f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(34f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::WrapReverse, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node0, 31f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node0, 70f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 32f32, "height of node {:?}. Expected {}. Actual {}", node1, 32f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node1, 70f32, location.x); assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node1, 31f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node2, 33f32, size.height); assert_eq!(location.x, 70f32, "x of node {:?}. Expected {}. Actual {}", node2, 70f32, location.x); assert_eq!(location.y, 63f32, "y of node {:?}. Expected {}. Actual {}", node2, 63f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); assert_eq!(size.height, 34f32, "height of node {:?}. Expected {}. Actual {}", node3, 34f32, size.height); assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node3, 20f32, location.x); diff --git a/tests/generated/wrap_reverse_column_fixed_size.rs b/tests/generated/wrap_reverse_column_fixed_size.rs index 08a4ab276..24bba3db5 100644 --- a/tests/generated/wrap_reverse_column_fixed_size.rs +++ b/tests/generated/wrap_reverse_column_fixed_size.rs @@ -3,96 +3,84 @@ fn wrap_reverse_column_fixed_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(10f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(100f32), }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node0, 135f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node1, 135f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node2, 135f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 135f32, "x of node {:?}. Expected {}. Actual {}", node3, 135f32, location.x); assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); assert_eq!(location.x, 35f32, "x of node {:?}. Expected {}. Actual {}", node4, 35f32, location.x); diff --git a/tests/generated/wrap_reverse_row.rs b/tests/generated/wrap_reverse_row.rs index 6fedc5585..fd9ee2c66 100644 --- a/tests/generated/wrap_reverse_row.rs +++ b/tests/generated/wrap_reverse_row.rs @@ -3,77 +3,67 @@ fn wrap_reverse_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(31f32), - height: taffy::style::Dimension::Length(30f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(31f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(32f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(33f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(34f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(32f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(33f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(34f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::WrapReverse, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 31f32, "width of node {:?}. Expected {}. Actual {}", node0, 31f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node1, 32f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); assert_eq!(location.x, 31f32, "x of node {:?}. Expected {}. Actual {}", node1, 31f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node2, 33f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); assert_eq!(location.x, 63f32, "x of node {:?}. Expected {}. Actual {}", node2, 63f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node3, 34f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); diff --git a/tests/generated/wrap_reverse_row_align_content_center.rs b/tests/generated/wrap_reverse_row_align_content_center.rs index f95f598ec..e6446de17 100644 --- a/tests/generated/wrap_reverse_row_align_content_center.rs +++ b/tests/generated/wrap_reverse_row_align_content_center.rs @@ -3,92 +3,80 @@ fn wrap_reverse_row_align_content_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(10f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_content: Some(taffy::style::AlignContent::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_content: Some(taffy::style::AlignContent::Center), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); diff --git a/tests/generated/wrap_reverse_row_align_content_flex_start.rs b/tests/generated/wrap_reverse_row_align_content_flex_start.rs index 833ab4db7..17b327dd5 100644 --- a/tests/generated/wrap_reverse_row_align_content_flex_start.rs +++ b/tests/generated/wrap_reverse_row_align_content_flex_start.rs @@ -3,92 +3,80 @@ fn wrap_reverse_row_align_content_flex_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(10f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_content: Some(taffy::style::AlignContent::FlexStart), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_content: Some(taffy::style::AlignContent::FlexStart), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); diff --git a/tests/generated/wrap_reverse_row_align_content_space_around.rs b/tests/generated/wrap_reverse_row_align_content_space_around.rs index 94f5d5799..f88b13ee8 100644 --- a/tests/generated/wrap_reverse_row_align_content_space_around.rs +++ b/tests/generated/wrap_reverse_row_align_content_space_around.rs @@ -3,92 +3,80 @@ fn wrap_reverse_row_align_content_space_around() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(10f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_content: Some(taffy::style::AlignContent::SpaceAround), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_content: Some(taffy::style::AlignContent::SpaceAround), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); diff --git a/tests/generated/wrap_reverse_row_align_content_stretch.rs b/tests/generated/wrap_reverse_row_align_content_stretch.rs index e35d9869e..095be00c2 100644 --- a/tests/generated/wrap_reverse_row_align_content_stretch.rs +++ b/tests/generated/wrap_reverse_row_align_content_stretch.rs @@ -3,92 +3,80 @@ fn wrap_reverse_row_align_content_stretch() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(10f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_content: Some(taffy::style::AlignContent::Stretch), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x); diff --git a/tests/generated/wrap_reverse_row_single_line_different_size.rs b/tests/generated/wrap_reverse_row_single_line_different_size.rs index 0eb98c75c..c161dff95 100644 --- a/tests/generated/wrap_reverse_row_single_line_different_size.rs +++ b/tests/generated/wrap_reverse_row_single_line_different_size.rs @@ -3,92 +3,80 @@ fn wrap_reverse_row_single_line_different_size() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(10f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(40f32), + }, + ..Default::default() + }); + let node4 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(50f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_content: Some(taffy::style::AlignContent::FlexStart), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(300f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(40f32), - }, - ..Default::default() - }) - .unwrap(); - let node4 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(50f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_content: Some(taffy::style::AlignContent::FlexStart), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(300f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3, node4], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3, node4], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node, 300f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height); assert_eq!(location.x, 90f32, "x of node {:?}. Expected {}. Actual {}", node3, 90f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node4).unwrap(); + let Layout { size, location, .. } = taffy.layout(node4); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width); assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height); assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node4, 120f32, location.x); diff --git a/tests/generated/wrap_row.rs b/tests/generated/wrap_row.rs index a3c40ac1f..a07ee1d6d 100644 --- a/tests/generated/wrap_row.rs +++ b/tests/generated/wrap_row.rs @@ -3,77 +3,67 @@ fn wrap_row() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(31f32), - height: taffy::style::Dimension::Length(30f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(31f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(32f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(33f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(34f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(32f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(33f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(34f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 31f32, "width of node {:?}. Expected {}. Actual {}", node0, 31f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 32f32, "width of node {:?}. Expected {}. Actual {}", node1, 32f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node1, 30f32, size.height); assert_eq!(location.x, 31f32, "x of node {:?}. Expected {}. Actual {}", node1, 31f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node2, 33f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); assert_eq!(location.x, 63f32, "x of node {:?}. Expected {}. Actual {}", node2, 63f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node3, 34f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); diff --git a/tests/generated/wrap_row_align_items_center.rs b/tests/generated/wrap_row_align_items_center.rs index 4445ef224..3e0b24b7e 100644 --- a/tests/generated/wrap_row_align_items_center.rs +++ b/tests/generated/wrap_row_align_items_center.rs @@ -3,78 +3,68 @@ fn wrap_row_align_items_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(10f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); diff --git a/tests/generated/wrap_row_align_items_flex_end.rs b/tests/generated/wrap_row_align_items_flex_end.rs index 78f3a97d9..fe1df0291 100644 --- a/tests/generated/wrap_row_align_items_flex_end.rs +++ b/tests/generated/wrap_row_align_items_flex_end.rs @@ -3,78 +3,68 @@ fn wrap_row_align_items_flex_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(10f32), - }, + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(10f32), + }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node3 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(30f32), + height: taffy::style::Dimension::Length(30f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::FlexEnd), + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node3 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(30f32), - height: taffy::style::Dimension::Length(30f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: Some(taffy::style::AlignItems::FlexEnd), - size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() }, - ..Default::default() - }, - &[node0, node1, node2, node3], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2, node3], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width); assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width); assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x); assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height); assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + let Layout { size, location, .. } = taffy.layout(node3); assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width); assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); diff --git a/tests/generated/wrapped_column_max_height.rs b/tests/generated/wrapped_column_max_height.rs index 6453a8437..b46a3d39e 100644 --- a/tests/generated/wrapped_column_max_height.rs +++ b/tests/generated/wrapped_column_max_height.rs @@ -3,77 +3,69 @@ fn wrapped_column_max_height() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { + let node0 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(500f32), + }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(20f32), + right: taffy::style::LengthPercentageAuto::Length(20f32), + top: taffy::style::LengthPercentageAuto::Length(20f32), + bottom: taffy::style::LengthPercentageAuto::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::Center), + align_content: Some(taffy::style::AlignContent::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), + width: taffy::style::Dimension::Length(700f32), height: taffy::style::Dimension::Length(500f32), }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(20f32), - right: taffy::style::LengthPercentageAuto::Length(20f32), - top: taffy::style::LengthPercentageAuto::Length(20f32), - bottom: taffy::style::LengthPercentageAuto::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: Some(taffy::style::AlignItems::Center), - align_content: Some(taffy::style::AlignContent::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(700f32), - height: taffy::style::Dimension::Length(500f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 700f32, "width of node {:?}. Expected {}. Actual {}", node, 700f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height); assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node0, 250f32, location.x); assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node1, 200f32, size.height); assert_eq!(location.x, 200f32, "x of node {:?}. Expected {}. Actual {}", node1, 200f32, location.x); assert_eq!(location.y, 250f32, "y of node {:?}. Expected {}. Actual {}", node1, 250f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 420f32, "x of node {:?}. Expected {}. Actual {}", node2, 420f32, location.x); diff --git a/tests/generated/wrapped_column_max_height_flex.rs b/tests/generated/wrapped_column_max_height_flex.rs index 64f33d17d..8167086a8 100644 --- a/tests/generated/wrapped_column_max_height_flex.rs +++ b/tests/generated/wrapped_column_max_height_flex.rs @@ -3,83 +3,75 @@ fn wrapped_column_max_height_flex() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), + let node0 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(500f32), + }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, + ..Default::default() + }); + let node1 = taffy.new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Length(20f32), + right: taffy::style::LengthPercentageAuto::Length(20f32), + top: taffy::style::LengthPercentageAuto::Length(20f32), + bottom: taffy::style::LengthPercentageAuto::Length(20f32), + }, + ..Default::default() + }); + let node2 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(100f32), + height: taffy::style::Dimension::Length(100f32), + }, + ..Default::default() + }); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::Center), + align_content: Some(taffy::style::AlignContent::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), + width: taffy::style::Dimension::Length(700f32), height: taffy::style::Dimension::Length(500f32), }, - max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, ..Default::default() - }) - .unwrap(); - let node1 = taffy - .new_leaf(taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Length(20f32), - right: taffy::style::LengthPercentageAuto::Length(20f32), - top: taffy::style::LengthPercentageAuto::Length(20f32), - bottom: taffy::style::LengthPercentageAuto::Length(20f32), - }, - ..Default::default() - }) - .unwrap(); - let node2 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(100f32), - height: taffy::style::Dimension::Length(100f32), - }, - ..Default::default() - }) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: Some(taffy::style::AlignItems::Center), - align_content: Some(taffy::style::AlignContent::Center), - justify_content: Some(taffy::style::JustifyContent::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(700f32), - height: taffy::style::Dimension::Length(500f32), - }, - ..Default::default() - }, - &[node0, node1, node2], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0, node1, node2], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 700f32, "width of node {:?}. Expected {}. Actual {}", node, 700f32, size.width); assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node0, 180f32, size.height); assert_eq!(location.x, 300f32, "x of node {:?}. Expected {}. Actual {}", node0, 300f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + let Layout { size, location, .. } = taffy.layout(node1); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node1, 200f32, size.width); assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node1, 180f32, size.height); assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node1, 250f32, location.x); assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node1, 200f32, location.y); - let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + let Layout { size, location, .. } = taffy.layout(node2); assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width); assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height); assert_eq!(location.x, 300f32, "x of node {:?}. Expected {}. Actual {}", node2, 300f32, location.x); diff --git a/tests/generated/wrapped_row_within_align_items_center.rs b/tests/generated/wrapped_row_within_align_items_center.rs index f9254802b..741e17206 100644 --- a/tests/generated/wrapped_row_within_align_items_center.rs +++ b/tests/generated/wrapped_row_within_align_items_center.rs @@ -3,64 +3,56 @@ fn wrapped_row_within_align_items_center() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(80f32), + }, + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(80f32), + height: taffy::style::Dimension::Length(80f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, + &[node00, node01], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(80f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(80f32), - height: taffy::style::Dimension::Length(80f32), - }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, - &[node00, node01], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::Center), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node0, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node00, 150f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node00, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node01, 80f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node01, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); diff --git a/tests/generated/wrapped_row_within_align_items_flex_end.rs b/tests/generated/wrapped_row_within_align_items_flex_end.rs index 165166a40..0b0650e09 100644 --- a/tests/generated/wrapped_row_within_align_items_flex_end.rs +++ b/tests/generated/wrapped_row_within_align_items_flex_end.rs @@ -3,64 +3,56 @@ fn wrapped_row_within_align_items_flex_end() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(80f32), + }, + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(80f32), + height: taffy::style::Dimension::Length(80f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, + &[node00, node01], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::FlexEnd), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(80f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(80f32), - height: taffy::style::Dimension::Length(80f32), - }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, - &[node00, node01], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::FlexEnd), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node0, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node00, 150f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node00, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node01, 80f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node01, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); diff --git a/tests/generated/wrapped_row_within_align_items_flex_start.rs b/tests/generated/wrapped_row_within_align_items_flex_start.rs index ad30aedee..beec819b0 100644 --- a/tests/generated/wrapped_row_within_align_items_flex_start.rs +++ b/tests/generated/wrapped_row_within_align_items_flex_start.rs @@ -3,64 +3,56 @@ fn wrapped_row_within_align_items_flex_start() { #[allow(unused_imports)] use taffy::{prelude::*, tree::Layout}; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_leaf(taffy::style::Style { + let node00 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(150f32), + height: taffy::style::Dimension::Length(80f32), + }, + ..Default::default() + }); + let node01 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(80f32), + height: taffy::style::Dimension::Length(80f32), + }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, + &[node00, node01], + ); + let node = taffy.new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::FlexStart), size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(150f32), - height: taffy::style::Dimension::Length(80f32), + width: taffy::style::Dimension::Length(200f32), + height: taffy::style::Dimension::Length(200f32), }, ..Default::default() - }) - .unwrap(); - let node01 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(80f32), - height: taffy::style::Dimension::Length(80f32), - }, - ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, - &[node00, node01], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - flex_direction: taffy::style::FlexDirection::Column, - align_items: Some(taffy::style::AlignItems::FlexStart), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200f32), - height: taffy::style::Dimension::Length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + }, + &[node0], + ); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT); println!("\nComputed tree:"); taffy::util::print_tree(&taffy, node); println!(); - let Layout { size, location, .. } = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = taffy.layout(node); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = taffy.layout(node0); assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width); assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node0, 160f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node00).unwrap(); + let Layout { size, location, .. } = taffy.layout(node00); assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node00, 150f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node00, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); - let Layout { size, location, .. } = taffy.layout(node01).unwrap(); + let Layout { size, location, .. } = taffy.layout(node01); assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node01, 80f32, size.width); assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node01, 80f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01, 0f32, location.x); diff --git a/tests/measure.rs b/tests/measure.rs index 5948387d0..8cb2e942a 100644 --- a/tests/measure.rs +++ b/tests/measure.rs @@ -6,444 +6,385 @@ mod measure { #[test] fn measure_root() { let mut taffy = Taffy::new(); - let node = taffy - .new_leaf_with_measure( - Style::default(), - MeasureFunc::Raw(|known_dimensions, _available_space| Size { - width: known_dimensions.width.unwrap_or(100.0), - height: known_dimensions.height.unwrap_or(100.0), - }), - ) - .unwrap(); - - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); - - assert_eq!(taffy.layout(node).unwrap().size.width, 100.0); - assert_eq!(taffy.layout(node).unwrap().size.height, 100.0); + let node = taffy.new_leaf_with_measure( + Style::default(), + MeasureFunc::Raw(|known_dimensions, _available_space| Size { + width: known_dimensions.width.unwrap_or(100.0), + height: known_dimensions.height.unwrap_or(100.0), + }), + ); + + taffy.compute_layout(node, Size::MAX_CONTENT); + + assert_eq!(taffy.layout(node).size.width, 100.0); + assert_eq!(taffy.layout(node).size.height, 100.0); } #[test] fn measure_child() { let mut taffy = Taffy::new(); - let child = taffy - .new_leaf_with_measure( - Style::default(), - MeasureFunc::Raw(|known_dimensions, _available_space| Size { - width: known_dimensions.width.unwrap_or(100.0), - height: known_dimensions.height.unwrap_or(100.0), - }), - ) - .unwrap(); + let child = taffy.new_leaf_with_measure( + Style::default(), + MeasureFunc::Raw(|known_dimensions, _available_space| Size { + width: known_dimensions.width.unwrap_or(100.0), + height: known_dimensions.height.unwrap_or(100.0), + }), + ); - let node = taffy.new_with_children(Style::default(), &[child]).unwrap(); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); + let node = taffy.new_with_children(Style::default(), &[child]); + taffy.compute_layout(node, Size::MAX_CONTENT); - assert_eq!(taffy.layout(node).unwrap().size.width, 100.0); - assert_eq!(taffy.layout(node).unwrap().size.height, 100.0); + assert_eq!(taffy.layout(node).size.width, 100.0); + assert_eq!(taffy.layout(node).size.height, 100.0); - assert_eq!(taffy.layout(child).unwrap().size.width, 100.0); - assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + assert_eq!(taffy.layout(child).size.width, 100.0); + assert_eq!(taffy.layout(child).size.height, 100.0); } #[test] fn measure_child_constraint() { let mut taffy = Taffy::new(); - let child = taffy - .new_leaf_with_measure( - Style::default(), - MeasureFunc::Raw(|known_dimensions, _available_space| Size { - width: known_dimensions.width.unwrap_or(100.0), - height: known_dimensions.height.unwrap_or(100.0), - }), - ) - .unwrap(); - - let node = taffy - .new_with_children( - Style { size: Size { width: Dimension::Length(50.0), height: auto() }, ..Default::default() }, - &[child], - ) - .unwrap(); - - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); + let child = taffy.new_leaf_with_measure( + Style::default(), + MeasureFunc::Raw(|known_dimensions, _available_space| Size { + width: known_dimensions.width.unwrap_or(100.0), + height: known_dimensions.height.unwrap_or(100.0), + }), + ); + + let node = taffy.new_with_children( + Style { size: Size { width: Dimension::Length(50.0), height: auto() }, ..Default::default() }, + &[child], + ); + + taffy.compute_layout(node, Size::MAX_CONTENT); // Parent - assert_eq!(taffy.layout(node).unwrap().size.width, 50.0); - assert_eq!(taffy.layout(node).unwrap().size.height, 100.0); + assert_eq!(taffy.layout(node).size.width, 50.0); + assert_eq!(taffy.layout(node).size.height, 100.0); // Child - assert_eq!(taffy.layout(child).unwrap().size.width, 100.0); - assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + assert_eq!(taffy.layout(child).size.width, 100.0); + assert_eq!(taffy.layout(child).size.height, 100.0); } #[test] fn measure_child_constraint_padding_parent() { let mut taffy = Taffy::new(); - let child = taffy - .new_leaf_with_measure( - Style::default(), - MeasureFunc::Raw(|known_dimensions, _available_space| Size { - width: known_dimensions.width.unwrap_or(100.0), - height: known_dimensions.height.unwrap_or(100.0), - }), - ) - .unwrap(); - - let node = taffy - .new_with_children( - Style { - size: Size { width: Dimension::Length(50.0), height: auto() }, - padding: Rect { - left: LengthPercentage::Length(10.0), - right: LengthPercentage::Length(10.0), - top: LengthPercentage::Length(10.0), - bottom: LengthPercentage::Length(10.0), - }, - ..Default::default() + let child = taffy.new_leaf_with_measure( + Style::default(), + MeasureFunc::Raw(|known_dimensions, _available_space| Size { + width: known_dimensions.width.unwrap_or(100.0), + height: known_dimensions.height.unwrap_or(100.0), + }), + ); + + let node = taffy.new_with_children( + Style { + size: Size { width: Dimension::Length(50.0), height: auto() }, + padding: Rect { + left: LengthPercentage::Length(10.0), + right: LengthPercentage::Length(10.0), + top: LengthPercentage::Length(10.0), + bottom: LengthPercentage::Length(10.0), }, - &[child], - ) - .unwrap(); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); - - assert_eq!(taffy.layout(node).unwrap().location.x, 0.0); - assert_eq!(taffy.layout(node).unwrap().location.y, 0.0); - assert_eq!(taffy.layout(node).unwrap().size.width, 50.0); - assert_eq!(taffy.layout(node).unwrap().size.height, 120.0); - - assert_eq!(taffy.layout(child).unwrap().location.x, 10.0); - assert_eq!(taffy.layout(child).unwrap().location.y, 10.0); - assert_eq!(taffy.layout(child).unwrap().size.width, 100.0); - assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + ..Default::default() + }, + &[child], + ); + taffy.compute_layout(node, Size::MAX_CONTENT); + + assert_eq!(taffy.layout(node).location.x, 0.0); + assert_eq!(taffy.layout(node).location.y, 0.0); + assert_eq!(taffy.layout(node).size.width, 50.0); + assert_eq!(taffy.layout(node).size.height, 120.0); + + assert_eq!(taffy.layout(child).location.x, 10.0); + assert_eq!(taffy.layout(child).location.y, 10.0); + assert_eq!(taffy.layout(child).size.width, 100.0); + assert_eq!(taffy.layout(child).size.height, 100.0); } #[test] fn measure_child_with_flex_grow() { let mut taffy = Taffy::new(); - let child0 = taffy - .new_leaf(Style { - size: Size { width: Dimension::Length(50.0), height: Dimension::Length(50.0) }, - ..Default::default() - }) - .unwrap(); - - let child1 = taffy - .new_leaf_with_measure( - Style { flex_grow: 1.0, ..Default::default() }, - MeasureFunc::Raw(|known_dimensions, _available_space| Size { - width: known_dimensions.width.unwrap_or(10.0), - height: known_dimensions.height.unwrap_or(50.0), - }), - ) - .unwrap(); - - let node = taffy - .new_with_children( - Style { size: Size { width: Dimension::Length(100.0), height: auto() }, ..Default::default() }, - &[child0, child1], - ) - .unwrap(); - - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); - - assert_eq!(taffy.layout(child1).unwrap().size.width, 50.0); - assert_eq!(taffy.layout(child1).unwrap().size.height, 50.0); + let child0 = taffy.new_leaf(Style { + size: Size { width: Dimension::Length(50.0), height: Dimension::Length(50.0) }, + ..Default::default() + }); + + let child1 = taffy.new_leaf_with_measure( + Style { flex_grow: 1.0, ..Default::default() }, + MeasureFunc::Raw(|known_dimensions, _available_space| Size { + width: known_dimensions.width.unwrap_or(10.0), + height: known_dimensions.height.unwrap_or(50.0), + }), + ); + + let node = taffy.new_with_children( + Style { size: Size { width: Dimension::Length(100.0), height: auto() }, ..Default::default() }, + &[child0, child1], + ); + + taffy.compute_layout(node, Size::MAX_CONTENT); + + assert_eq!(taffy.layout(child1).size.width, 50.0); + assert_eq!(taffy.layout(child1).size.height, 50.0); } #[test] fn measure_child_with_flex_shrink() { let mut taffy = Taffy::new(); - let child0 = taffy - .new_leaf(Style { - size: Size { width: Dimension::Length(50.0), height: Dimension::Length(50.0) }, - flex_shrink: 0.0, - ..Default::default() - }) - .unwrap(); - - let child1 = taffy - .new_leaf_with_measure( - Style::default(), - MeasureFunc::Raw(|known_dimensions, _available_space| Size { - width: known_dimensions.width.unwrap_or(100.0), - height: known_dimensions.height.unwrap_or(50.0), - }), - ) - .unwrap(); - - let node = taffy - .new_with_children( - Style { size: Size { width: Dimension::Length(100.0), height: auto() }, ..Default::default() }, - &[child0, child1], - ) - .unwrap(); - - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); - - assert_eq!(taffy.layout(child1).unwrap().size.width, 100.0); - assert_eq!(taffy.layout(child1).unwrap().size.height, 50.0); + let child0 = taffy.new_leaf(Style { + size: Size { width: Dimension::Length(50.0), height: Dimension::Length(50.0) }, + flex_shrink: 0.0, + ..Default::default() + }); + + let child1 = taffy.new_leaf_with_measure( + Style::default(), + MeasureFunc::Raw(|known_dimensions, _available_space| Size { + width: known_dimensions.width.unwrap_or(100.0), + height: known_dimensions.height.unwrap_or(50.0), + }), + ); + + let node = taffy.new_with_children( + Style { size: Size { width: Dimension::Length(100.0), height: auto() }, ..Default::default() }, + &[child0, child1], + ); + + taffy.compute_layout(node, Size::MAX_CONTENT); + + assert_eq!(taffy.layout(child1).size.width, 100.0); + assert_eq!(taffy.layout(child1).size.height, 50.0); } #[test] fn remeasure_child_after_growing() { let mut taffy = Taffy::new(); - let child0 = taffy - .new_leaf(Style { - size: Size { width: Dimension::Length(50.0), height: Dimension::Length(50.0) }, + let child0 = taffy.new_leaf(Style { + size: Size { width: Dimension::Length(50.0), height: Dimension::Length(50.0) }, + ..Default::default() + }); + + let child1 = taffy.new_leaf_with_measure( + Style { flex_grow: 1.0, ..Default::default() }, + MeasureFunc::Raw(|known_dimensions, _available_space| { + let width = known_dimensions.width.unwrap_or(10.0); + let height = known_dimensions.height.unwrap_or(width * 2.0); + Size { width, height } + }), + ); + + let node = taffy.new_with_children( + Style { + size: Size { width: Dimension::Length(100.0), height: auto() }, + align_items: Some(AlignItems::Start), ..Default::default() - }) - .unwrap(); - - let child1 = taffy - .new_leaf_with_measure( - Style { flex_grow: 1.0, ..Default::default() }, - MeasureFunc::Raw(|known_dimensions, _available_space| { - let width = known_dimensions.width.unwrap_or(10.0); - let height = known_dimensions.height.unwrap_or(width * 2.0); - Size { width, height } - }), - ) - .unwrap(); - - let node = taffy - .new_with_children( - Style { - size: Size { width: Dimension::Length(100.0), height: auto() }, - align_items: Some(AlignItems::Start), - ..Default::default() - }, - &[child0, child1], - ) - .unwrap(); + }, + &[child0, child1], + ); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); + taffy.compute_layout(node, Size::MAX_CONTENT); - assert_eq!(taffy.layout(child1).unwrap().size.width, 50.0); - assert_eq!(taffy.layout(child1).unwrap().size.height, 100.0); + assert_eq!(taffy.layout(child1).size.width, 50.0); + assert_eq!(taffy.layout(child1).size.height, 100.0); } #[test] fn remeasure_child_after_shrinking() { let mut taffy = Taffy::new(); - let child0 = taffy - .new_leaf(Style { - size: Size { width: Dimension::Length(50.0), height: Dimension::Length(50.0) }, - flex_shrink: 0.0, + let child0 = taffy.new_leaf(Style { + size: Size { width: Dimension::Length(50.0), height: Dimension::Length(50.0) }, + flex_shrink: 0.0, + ..Default::default() + }); + + let child1 = taffy.new_leaf_with_measure( + Style::default(), + MeasureFunc::Raw(|known_dimensions, _available_space| { + let width = known_dimensions.width.unwrap_or(100.0); + let height = known_dimensions.height.unwrap_or(width * 2.0); + Size { width, height } + }), + ); + + let node = taffy.new_with_children( + Style { + size: Size { width: Dimension::Length(100.0), height: auto() }, + align_items: Some(AlignItems::Start), ..Default::default() - }) - .unwrap(); - - let child1 = taffy - .new_leaf_with_measure( - Style::default(), - MeasureFunc::Raw(|known_dimensions, _available_space| { - let width = known_dimensions.width.unwrap_or(100.0); - let height = known_dimensions.height.unwrap_or(width * 2.0); - Size { width, height } - }), - ) - .unwrap(); - - let node = taffy - .new_with_children( - Style { - size: Size { width: Dimension::Length(100.0), height: auto() }, - align_items: Some(AlignItems::Start), - ..Default::default() - }, - &[child0, child1], - ) - .unwrap(); + }, + &[child0, child1], + ); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); + taffy.compute_layout(node, Size::MAX_CONTENT); - assert_eq!(taffy.layout(child1).unwrap().size.width, 100.0); - assert_eq!(taffy.layout(child1).unwrap().size.height, 200.0); + assert_eq!(taffy.layout(child1).size.width, 100.0); + assert_eq!(taffy.layout(child1).size.height, 200.0); } #[test] fn remeasure_child_after_stretching() { let mut taffy = Taffy::new(); - let child = taffy - .new_leaf_with_measure( - Style::default(), - MeasureFunc::Raw(|known_dimensions, _available_space| { - let height = known_dimensions.height.unwrap_or(50.0); - let width = known_dimensions.width.unwrap_or(height); - Size { width, height } - }), - ) - .unwrap(); - - let node = taffy - .new_with_children( - Style { - size: Size { width: Dimension::Length(100.0), height: Dimension::Length(100.0) }, - ..Default::default() - }, - &[child], - ) - .unwrap(); + let child = taffy.new_leaf_with_measure( + Style::default(), + MeasureFunc::Raw(|known_dimensions, _available_space| { + let height = known_dimensions.height.unwrap_or(50.0); + let width = known_dimensions.width.unwrap_or(height); + Size { width, height } + }), + ); + + let node = taffy.new_with_children( + Style { + size: Size { width: Dimension::Length(100.0), height: Dimension::Length(100.0) }, + ..Default::default() + }, + &[child], + ); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); + taffy.compute_layout(node, Size::MAX_CONTENT); - assert_eq!(taffy.layout(child).unwrap().size.width, 100.0); - assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + assert_eq!(taffy.layout(child).size.width, 100.0); + assert_eq!(taffy.layout(child).size.height, 100.0); } #[test] fn width_overrides_measure() { let mut taffy = Taffy::new(); - let child = taffy - .new_leaf_with_measure( - Style { size: Size { width: Dimension::Length(50.0), height: auto() }, ..Default::default() }, - MeasureFunc::Raw(|known_dimensions, _available_space| Size { - width: known_dimensions.width.unwrap_or(100.0), - height: known_dimensions.height.unwrap_or(100.0), - }), - ) - .unwrap(); - - let node = taffy.new_with_children(Style::default(), &[child]).unwrap(); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); - - assert_eq!(taffy.layout(child).unwrap().size.width, 50.0); - assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + let child = taffy.new_leaf_with_measure( + Style { size: Size { width: Dimension::Length(50.0), height: auto() }, ..Default::default() }, + MeasureFunc::Raw(|known_dimensions, _available_space| Size { + width: known_dimensions.width.unwrap_or(100.0), + height: known_dimensions.height.unwrap_or(100.0), + }), + ); + + let node = taffy.new_with_children(Style::default(), &[child]); + taffy.compute_layout(node, Size::MAX_CONTENT); + + assert_eq!(taffy.layout(child).size.width, 50.0); + assert_eq!(taffy.layout(child).size.height, 100.0); } #[test] fn height_overrides_measure() { let mut taffy = Taffy::new(); - let child = taffy - .new_leaf_with_measure( - Style { size: Size { width: auto(), height: Dimension::Length(50.0) }, ..Default::default() }, - MeasureFunc::Raw(|known_dimensions, _available_space| Size { - width: known_dimensions.width.unwrap_or(100.0), - height: known_dimensions.height.unwrap_or(100.0), - }), - ) - .unwrap(); - - let node = taffy.new_with_children(Style::default(), &[child]).unwrap(); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); - - assert_eq!(taffy.layout(child).unwrap().size.width, 100.0); - assert_eq!(taffy.layout(child).unwrap().size.height, 50.0); + let child = taffy.new_leaf_with_measure( + Style { size: Size { width: auto(), height: Dimension::Length(50.0) }, ..Default::default() }, + MeasureFunc::Raw(|known_dimensions, _available_space| Size { + width: known_dimensions.width.unwrap_or(100.0), + height: known_dimensions.height.unwrap_or(100.0), + }), + ); + + let node = taffy.new_with_children(Style::default(), &[child]); + taffy.compute_layout(node, Size::MAX_CONTENT); + + assert_eq!(taffy.layout(child).size.width, 100.0); + assert_eq!(taffy.layout(child).size.height, 50.0); } #[test] fn flex_basis_overrides_measure() { let mut taffy = Taffy::new(); - let child0 = taffy - .new_leaf(Style { flex_basis: Dimension::Length(50.0), flex_grow: 1.0, ..Default::default() }) - .unwrap(); - - let child1 = taffy - .new_leaf_with_measure( - Style { flex_basis: Dimension::Length(50.0), flex_grow: 1.0, ..Default::default() }, - MeasureFunc::Raw(|known_dimensions, _available_space| Size { - width: known_dimensions.width.unwrap_or(100.0), - height: known_dimensions.height.unwrap_or(100.0), - }), - ) - .unwrap(); - - let node = taffy - .new_with_children( - Style { - size: Size { width: Dimension::Length(200.0), height: Dimension::Length(100.0) }, - ..Default::default() - }, - &[child0, child1], - ) - .unwrap(); + let child0 = + taffy.new_leaf(Style { flex_basis: Dimension::Length(50.0), flex_grow: 1.0, ..Default::default() }); + + let child1 = taffy.new_leaf_with_measure( + Style { flex_basis: Dimension::Length(50.0), flex_grow: 1.0, ..Default::default() }, + MeasureFunc::Raw(|known_dimensions, _available_space| Size { + width: known_dimensions.width.unwrap_or(100.0), + height: known_dimensions.height.unwrap_or(100.0), + }), + ); + + let node = taffy.new_with_children( + Style { + size: Size { width: Dimension::Length(200.0), height: Dimension::Length(100.0) }, + ..Default::default() + }, + &[child0, child1], + ); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); + taffy.compute_layout(node, Size::MAX_CONTENT); - assert_eq!(taffy.layout(child0).unwrap().size.width, 100.0); - assert_eq!(taffy.layout(child0).unwrap().size.height, 100.0); - assert_eq!(taffy.layout(child1).unwrap().size.width, 100.0); - assert_eq!(taffy.layout(child1).unwrap().size.height, 100.0); + assert_eq!(taffy.layout(child0).size.width, 100.0); + assert_eq!(taffy.layout(child0).size.height, 100.0); + assert_eq!(taffy.layout(child1).size.width, 100.0); + assert_eq!(taffy.layout(child1).size.height, 100.0); } #[test] fn stretch_overrides_measure() { let mut taffy = Taffy::new(); - let child = taffy - .new_leaf_with_measure( - Style::default(), - MeasureFunc::Raw(|known_dimensions, _available_space| Size { - width: known_dimensions.width.unwrap_or(50.0), - height: known_dimensions.height.unwrap_or(50.0), - }), - ) - .unwrap(); - - let node = taffy - .new_with_children( - Style { - size: Size { width: Dimension::Length(100.0), height: Dimension::Length(100.0) }, - ..Default::default() - }, - &[child], - ) - .unwrap(); + let child = taffy.new_leaf_with_measure( + Style::default(), + MeasureFunc::Raw(|known_dimensions, _available_space| Size { + width: known_dimensions.width.unwrap_or(50.0), + height: known_dimensions.height.unwrap_or(50.0), + }), + ); + + let node = taffy.new_with_children( + Style { + size: Size { width: Dimension::Length(100.0), height: Dimension::Length(100.0) }, + ..Default::default() + }, + &[child], + ); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); + taffy.compute_layout(node, Size::MAX_CONTENT); - assert_eq!(taffy.layout(child).unwrap().size.width, 50.0); - assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + assert_eq!(taffy.layout(child).size.width, 50.0); + assert_eq!(taffy.layout(child).size.height, 100.0); } #[test] fn measure_absolute_child() { let mut taffy = Taffy::new(); - let child = taffy - .new_leaf_with_measure( - Style { position: Position::Absolute, ..Default::default() }, - MeasureFunc::Raw(|known_dimensions, _available_space| Size { - width: known_dimensions.width.unwrap_or(50.0), - height: known_dimensions.height.unwrap_or(50.0), - }), - ) - .unwrap(); - - let node = taffy - .new_with_children( - Style { - size: Size { width: Dimension::Length(100.0), height: Dimension::Length(100.0) }, - ..Default::default() - }, - &[child], - ) - .unwrap(); + let child = taffy.new_leaf_with_measure( + Style { position: Position::Absolute, ..Default::default() }, + MeasureFunc::Raw(|known_dimensions, _available_space| Size { + width: known_dimensions.width.unwrap_or(50.0), + height: known_dimensions.height.unwrap_or(50.0), + }), + ); + + let node = taffy.new_with_children( + Style { + size: Size { width: Dimension::Length(100.0), height: Dimension::Length(100.0) }, + ..Default::default() + }, + &[child], + ); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); + taffy.compute_layout(node, Size::MAX_CONTENT); - assert_eq!(taffy.layout(child).unwrap().size.width, 50.0); - assert_eq!(taffy.layout(child).unwrap().size.height, 50.0); + assert_eq!(taffy.layout(child).size.width, 50.0); + assert_eq!(taffy.layout(child).size.height, 50.0); } #[test] fn ignore_invalid_measure() { let mut taffy = Taffy::new(); - let child = taffy.new_leaf(Style { flex_grow: 1.0, ..Default::default() }).unwrap(); + let child = taffy.new_leaf(Style { flex_grow: 1.0, ..Default::default() }); - let node = taffy - .new_with_children( - Style { - size: Size { width: Dimension::Length(100.0), height: Dimension::Length(100.0) }, - ..Default::default() - }, - &[child], - ) - .unwrap(); + let node = taffy.new_with_children( + Style { + size: Size { width: Dimension::Length(100.0), height: Dimension::Length(100.0) }, + ..Default::default() + }, + &[child], + ); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); + taffy.compute_layout(node, Size::MAX_CONTENT); - assert_eq!(taffy.layout(child).unwrap().size.width, 100.0); - assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + assert_eq!(taffy.layout(child).size.width, 100.0); + assert_eq!(taffy.layout(child).size.height, 100.0); } } diff --git a/tests/min_max_overrides.rs b/tests/min_max_overrides.rs index 78f9d893c..381ef5e7a 100644 --- a/tests/min_max_overrides.rs +++ b/tests/min_max_overrides.rs @@ -7,66 +7,54 @@ mod min_max_overrides { fn min_overrides_max() { let mut taffy = Taffy::new(); - let child = taffy - .new_leaf(Style { - size: Size { width: Dimension::Length(50.0), height: Dimension::Length(50.0) }, - min_size: Size { width: Dimension::Length(100.0), height: Dimension::Length(100.0) }, - max_size: Size { width: Dimension::Length(10.0), height: Dimension::Length(10.0) }, - ..Default::default() - }) - .unwrap(); - - taffy - .compute_layout( - child, - Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(100.0) }, - ) - .unwrap(); - - assert_eq!(taffy.layout(child).unwrap().size, Size { width: 100.0, height: 100.0 }); + let child = taffy.new_leaf(Style { + size: Size { width: Dimension::Length(50.0), height: Dimension::Length(50.0) }, + min_size: Size { width: Dimension::Length(100.0), height: Dimension::Length(100.0) }, + max_size: Size { width: Dimension::Length(10.0), height: Dimension::Length(10.0) }, + ..Default::default() + }); + + taffy.compute_layout( + child, + Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(100.0) }, + ); + + assert_eq!(taffy.layout(child).size, Size { width: 100.0, height: 100.0 }); } #[test] fn max_overrides_size() { let mut taffy = Taffy::new(); - let child = taffy - .new_leaf(Style { - size: Size { width: Dimension::Length(50.0), height: Dimension::Length(50.0) }, - max_size: Size { width: Dimension::Length(10.0), height: Dimension::Length(10.0) }, - ..Default::default() - }) - .unwrap(); + let child = taffy.new_leaf(Style { + size: Size { width: Dimension::Length(50.0), height: Dimension::Length(50.0) }, + max_size: Size { width: Dimension::Length(10.0), height: Dimension::Length(10.0) }, + ..Default::default() + }); - taffy - .compute_layout( - child, - Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(100.0) }, - ) - .unwrap(); + taffy.compute_layout( + child, + Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(100.0) }, + ); - assert_eq!(taffy.layout(child).unwrap().size, Size { width: 10.0, height: 10.0 }); + assert_eq!(taffy.layout(child).size, Size { width: 10.0, height: 10.0 }); } #[test] fn min_overrides_size() { let mut taffy = Taffy::new(); - let child = taffy - .new_leaf(Style { - size: Size { width: Dimension::Length(50.0), height: Dimension::Length(50.0) }, - min_size: Size { width: Dimension::Length(100.0), height: Dimension::Length(100.0) }, - ..Default::default() - }) - .unwrap(); + let child = taffy.new_leaf(Style { + size: Size { width: Dimension::Length(50.0), height: Dimension::Length(50.0) }, + min_size: Size { width: Dimension::Length(100.0), height: Dimension::Length(100.0) }, + ..Default::default() + }); - taffy - .compute_layout( - child, - Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(100.0) }, - ) - .unwrap(); + taffy.compute_layout( + child, + Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(100.0) }, + ); - assert_eq!(taffy.layout(child).unwrap().size, Size { width: 100.0, height: 100.0 }); + assert_eq!(taffy.layout(child).size, Size { width: 100.0, height: 100.0 }); } } diff --git a/tests/relayout.rs b/tests/relayout.rs index 4e58245a2..bd0f707a3 100644 --- a/tests/relayout.rs +++ b/tests/relayout.rs @@ -3,56 +3,43 @@ use taffy::prelude::*; #[test] fn relayout() { let mut taffy = taffy::Taffy::new(); - let node1 = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { width: length(8.0), height: length(80.0) }, + let node1 = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: length(8.0), height: length(80.0) }, + ..Default::default() + }); + let node0 = taffy.new_with_children( + taffy::style::Style { + align_self: Some(taffy::prelude::AlignSelf::Center), + size: taffy::geometry::Size { width: Dimension::Auto, height: Dimension::Auto }, + // size: taffy::geometry::Size { width: Dimension::Percent(1.0), height: Dimension::Percent(1.0) }, + ..Default::default() + }, + &[node1], + ); + let node = taffy.new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { width: Dimension::Percent(1f32), height: Dimension::Percent(1f32) }, ..Default::default() - }) - .unwrap(); - let node0 = taffy - .new_with_children( - taffy::style::Style { - align_self: Some(taffy::prelude::AlignSelf::Center), - size: taffy::geometry::Size { width: Dimension::Auto, height: Dimension::Auto }, - // size: taffy::geometry::Size { width: Dimension::Percent(1.0), height: Dimension::Percent(1.0) }, - ..Default::default() - }, - &[node1], - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: Dimension::Percent(1f32), height: Dimension::Percent(1f32) }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); + }, + &[node0], + ); println!("0:"); - taffy - .compute_layout( - node, - taffy::geometry::Size { width: AvailableSpace::Definite(100f32), height: AvailableSpace::Definite(100f32) }, - ) - .unwrap(); - let initial = taffy.layout(node).unwrap().location; - let initial0 = taffy.layout(node0).unwrap().location; - let initial1 = taffy.layout(node1).unwrap().location; + taffy.compute_layout( + node, + taffy::geometry::Size { width: AvailableSpace::Definite(100f32), height: AvailableSpace::Definite(100f32) }, + ); + let initial = taffy.layout(node).location; + let initial0 = taffy.layout(node0).location; + let initial1 = taffy.layout(node1).location; for i in 1..10 { println!("\n\n{i}:"); - taffy - .compute_layout( - node, - taffy::geometry::Size { - width: AvailableSpace::Definite(100f32), - height: AvailableSpace::Definite(100f32), - }, - ) - .unwrap(); - assert_eq!(taffy.layout(node).unwrap().location, initial); - assert_eq!(taffy.layout(node0).unwrap().location, initial0); - assert_eq!(taffy.layout(node1).unwrap().location, initial1); + taffy.compute_layout( + node, + taffy::geometry::Size { width: AvailableSpace::Definite(100f32), height: AvailableSpace::Definite(100f32) }, + ); + assert_eq!(taffy.layout(node).location, initial); + assert_eq!(taffy.layout(node0).location, initial0); + assert_eq!(taffy.layout(node1).location, initial1); } } @@ -72,29 +59,29 @@ fn toggle_root_display_none() { // Setup let mut taffy = taffy::Taffy::new(); - let node = taffy.new_leaf(hidden_style.clone()).unwrap(); + let node = taffy.new_leaf(hidden_style.clone()); // Layout 1 (None) - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(node).unwrap(); + taffy.compute_layout(node, Size::MAX_CONTENT); + let layout = taffy.layout(node); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 0.0); assert_eq!(layout.size.height, 0.0); // Layout 2 (Flex) - taffy.set_style(node, flex_style).unwrap(); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(node).unwrap(); + taffy.set_style(node, flex_style); + taffy.compute_layout(node, Size::MAX_CONTENT); + let layout = taffy.layout(node); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 100.0); assert_eq!(layout.size.height, 100.0); // Layout 3 (None) - taffy.set_style(node, hidden_style).unwrap(); - taffy.compute_layout(node, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(node).unwrap(); + taffy.set_style(node, hidden_style); + taffy.compute_layout(node, Size::MAX_CONTENT); + let layout = taffy.layout(node); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 0.0); @@ -107,33 +94,30 @@ fn toggle_root_display_none_with_children() { let mut taffy = taffy::Taffy::new(); - let child = taffy - .new_leaf(Style { size: Size { width: length(800.0), height: length(100.0) }, ..Default::default() }) - .unwrap(); - - let parent = taffy - .new_with_children( - Style { size: Size { width: length(800.0), height: length(100.0) }, ..Default::default() }, - &[child], - ) - .unwrap(); - - let root = taffy.new_with_children(Style::default(), &[parent]).unwrap(); - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - assert_eq!(taffy.layout(child).unwrap().size.width, 800.0); - assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); - - taffy.set_style(root, Style { display: Display::None, ..Default::default() }).unwrap(); - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - assert_eq!(taffy.layout(child).unwrap().size.width, 0.0); - assert_eq!(taffy.layout(child).unwrap().size.height, 0.0); - - taffy.set_style(root, Style::default()).unwrap(); - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - assert_eq!(taffy.layout(parent).unwrap().size.width, 800.0); - assert_eq!(taffy.layout(parent).unwrap().size.height, 100.0); - assert_eq!(taffy.layout(child).unwrap().size.width, 800.0); - assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + let child = + taffy.new_leaf(Style { size: Size { width: length(800.0), height: length(100.0) }, ..Default::default() }); + + let parent = taffy.new_with_children( + Style { size: Size { width: length(800.0), height: length(100.0) }, ..Default::default() }, + &[child], + ); + + let root = taffy.new_with_children(Style::default(), &[parent]); + taffy.compute_layout(root, Size::MAX_CONTENT); + assert_eq!(taffy.layout(child).size.width, 800.0); + assert_eq!(taffy.layout(child).size.height, 100.0); + + taffy.set_style(root, Style { display: Display::None, ..Default::default() }); + taffy.compute_layout(root, Size::MAX_CONTENT); + assert_eq!(taffy.layout(child).size.width, 0.0); + assert_eq!(taffy.layout(child).size.height, 0.0); + + taffy.set_style(root, Style::default()); + taffy.compute_layout(root, Size::MAX_CONTENT); + assert_eq!(taffy.layout(parent).size.width, 800.0); + assert_eq!(taffy.layout(parent).size.height, 100.0); + assert_eq!(taffy.layout(child).size.width, 800.0); + assert_eq!(taffy.layout(child).size.height, 100.0); } #[test] @@ -152,30 +136,30 @@ fn toggle_flex_child_display_none() { // Setup let mut taffy = taffy::Taffy::new(); - let node = taffy.new_leaf(hidden_style.clone()).unwrap(); - let root = taffy.new_with_children(flex_style.clone(), &[node]).unwrap(); + let node = taffy.new_leaf(hidden_style.clone()); + let root = taffy.new_with_children(flex_style.clone(), &[node]); // Layout 1 (None) - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(node).unwrap(); + taffy.compute_layout(root, Size::MAX_CONTENT); + let layout = taffy.layout(node); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 0.0); assert_eq!(layout.size.height, 0.0); // Layout 2 (Flex) - taffy.set_style(node, flex_style).unwrap(); - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(node).unwrap(); + taffy.set_style(node, flex_style); + taffy.compute_layout(root, Size::MAX_CONTENT); + let layout = taffy.layout(node); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 100.0); assert_eq!(layout.size.height, 100.0); // Layout 3 (None) - taffy.set_style(node, hidden_style).unwrap(); - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(node).unwrap(); + taffy.set_style(node, hidden_style); + taffy.compute_layout(root, Size::MAX_CONTENT); + let layout = taffy.layout(node); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 0.0); @@ -198,30 +182,30 @@ fn toggle_flex_container_display_none() { // Setup let mut taffy = taffy::Taffy::new(); - let node = taffy.new_leaf(hidden_style.clone()).unwrap(); - let root = taffy.new_with_children(hidden_style.clone(), &[node]).unwrap(); + let node = taffy.new_leaf(hidden_style.clone()); + let root = taffy.new_with_children(hidden_style.clone(), &[node]); // Layout 1 (None) - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(root).unwrap(); + taffy.compute_layout(root, Size::MAX_CONTENT); + let layout = taffy.layout(root); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 0.0); assert_eq!(layout.size.height, 0.0); // Layout 2 (Flex) - taffy.set_style(root, flex_style).unwrap(); - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(root).unwrap(); + taffy.set_style(root, flex_style); + taffy.compute_layout(root, Size::MAX_CONTENT); + let layout = taffy.layout(root); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 100.0); assert_eq!(layout.size.height, 100.0); // Layout 3 (None) - taffy.set_style(root, hidden_style).unwrap(); - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(root).unwrap(); + taffy.set_style(root, hidden_style); + taffy.compute_layout(root, Size::MAX_CONTENT); + let layout = taffy.layout(root); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 0.0); @@ -244,30 +228,30 @@ fn toggle_grid_child_display_none() { // Setup let mut taffy = taffy::Taffy::new(); - let node = taffy.new_leaf(hidden_style.clone()).unwrap(); - let root = taffy.new_with_children(grid_style.clone(), &[node]).unwrap(); + let node = taffy.new_leaf(hidden_style.clone()); + let root = taffy.new_with_children(grid_style.clone(), &[node]); // Layout 1 (None) - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(node).unwrap(); + taffy.compute_layout(root, Size::MAX_CONTENT); + let layout = taffy.layout(node); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 0.0); assert_eq!(layout.size.height, 0.0); // Layout 2 (Flex) - taffy.set_style(node, grid_style).unwrap(); - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(node).unwrap(); + taffy.set_style(node, grid_style); + taffy.compute_layout(root, Size::MAX_CONTENT); + let layout = taffy.layout(node); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 100.0); assert_eq!(layout.size.height, 100.0); // Layout 3 (None) - taffy.set_style(node, hidden_style).unwrap(); - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(node).unwrap(); + taffy.set_style(node, hidden_style); + taffy.compute_layout(root, Size::MAX_CONTENT); + let layout = taffy.layout(node); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 0.0); @@ -290,30 +274,30 @@ fn toggle_grid_container_display_none() { // Setup let mut taffy = taffy::Taffy::new(); - let node = taffy.new_leaf(hidden_style.clone()).unwrap(); - let root = taffy.new_with_children(hidden_style.clone(), &[node]).unwrap(); + let node = taffy.new_leaf(hidden_style.clone()); + let root = taffy.new_with_children(hidden_style.clone(), &[node]); // Layout 1 (None) - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(root).unwrap(); + taffy.compute_layout(root, Size::MAX_CONTENT); + let layout = taffy.layout(root); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 0.0); assert_eq!(layout.size.height, 0.0); // Layout 2 (Flex) - taffy.set_style(root, grid_style).unwrap(); - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(root).unwrap(); + taffy.set_style(root, grid_style); + taffy.compute_layout(root, Size::MAX_CONTENT); + let layout = taffy.layout(root); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 100.0); assert_eq!(layout.size.height, 100.0); // Layout 3 (None) - taffy.set_style(root, hidden_style).unwrap(); - taffy.compute_layout(root, Size::MAX_CONTENT).unwrap(); - let layout = taffy.layout(root).unwrap(); + taffy.set_style(root, hidden_style); + taffy.compute_layout(root, Size::MAX_CONTENT); + let layout = taffy.layout(root); assert_eq!(layout.location.x, 0.0); assert_eq!(layout.location.y, 0.0); assert_eq!(layout.size.width, 0.0); diff --git a/tests/root_constraints.rs b/tests/root_constraints.rs index 9791fd28b..e068def69 100644 --- a/tests/root_constraints.rs +++ b/tests/root_constraints.rs @@ -5,26 +5,19 @@ mod root_constraints { #[test] fn root_with_percentage_size() { let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(1.0), - height: taffy::style::Dimension::Percent(1.0), - }, - ..Default::default() - }) - .unwrap(); - - taffy - .compute_layout( - node, - taffy::geometry::Size { - width: AvailableSpace::Definite(100.0), - height: AvailableSpace::Definite(200.0), - }, - ) - .unwrap(); - let layout = taffy.layout(node).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1.0), + height: taffy::style::Dimension::Percent(1.0), + }, + ..Default::default() + }); + + taffy.compute_layout( + node, + taffy::geometry::Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(200.0) }, + ); + let layout = taffy.layout(node); assert_eq!(layout.size.width, 100.0); assert_eq!(layout.size.height, 200.0); @@ -33,18 +26,13 @@ mod root_constraints { #[test] fn root_with_no_size() { let mut taffy = taffy::Taffy::new(); - let node = taffy.new_leaf(taffy::style::Style::default()).unwrap(); + let node = taffy.new_leaf(taffy::style::Style::default()); - taffy - .compute_layout( - node, - taffy::geometry::Size { - width: AvailableSpace::Definite(100.0), - height: AvailableSpace::Definite(100.0), - }, - ) - .unwrap(); - let layout = taffy.layout(node).unwrap(); + taffy.compute_layout( + node, + taffy::geometry::Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(100.0) }, + ); + let layout = taffy.layout(node); assert_eq!(layout.size.width, 0.0); assert_eq!(layout.size.height, 0.0); @@ -53,26 +41,19 @@ mod root_constraints { #[test] fn root_with_larger_size() { let mut taffy = taffy::Taffy::new(); - let node = taffy - .new_leaf(taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Length(200.0), - height: taffy::style::Dimension::Length(200.0), - }, - ..Default::default() - }) - .unwrap(); - - taffy - .compute_layout( - node, - taffy::geometry::Size { - width: AvailableSpace::Definite(100.0), - height: AvailableSpace::Definite(100.0), - }, - ) - .unwrap(); - let layout = taffy.layout(node).unwrap(); + let node = taffy.new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(200.0), + height: taffy::style::Dimension::Length(200.0), + }, + ..Default::default() + }); + + taffy.compute_layout( + node, + taffy::geometry::Size { width: AvailableSpace::Definite(100.0), height: AvailableSpace::Definite(100.0) }, + ); + let layout = taffy.layout(node); assert_eq!(layout.size.width, 200.0); assert_eq!(layout.size.height, 200.0); diff --git a/tests/rounding.rs b/tests/rounding.rs index 3e273afc0..c9c4c307a 100644 --- a/tests/rounding.rs +++ b/tests/rounding.rs @@ -6,24 +6,22 @@ fn rounding_doesnt_leave_gaps() { let mut taffy = Taffy::new(); let w_square = Size { width: length(100.3), height: length(100.3) }; - let child_a = taffy.new_leaf(Style { size: w_square, ..Default::default() }).unwrap(); - let child_b = taffy.new_leaf(Style { size: w_square, ..Default::default() }).unwrap(); + let child_a = taffy.new_leaf(Style { size: w_square, ..Default::default() }); + let child_b = taffy.new_leaf(Style { size: w_square, ..Default::default() }); - let root_node = taffy - .new_with_children( - Style { - size: Size { width: length(963.3333), height: length(1000.) }, - justify_content: Some(JustifyContent::Center), - ..Default::default() - }, - &[child_a, child_b], - ) - .unwrap(); + let root_node = taffy.new_with_children( + Style { + size: Size { width: length(963.3333), height: length(1000.) }, + justify_content: Some(JustifyContent::Center), + ..Default::default() + }, + &[child_a, child_b], + ); - taffy.compute_layout(root_node, Size::MAX_CONTENT).unwrap(); + taffy.compute_layout(root_node, Size::MAX_CONTENT); - let layout_a = taffy.layout(child_a).unwrap(); - let layout_b = taffy.layout(child_b).unwrap(); + let layout_a = taffy.layout(child_a); + let layout_b = taffy.layout(child_b); taffy::util::print_tree(&taffy, root_node); assert_eq!(layout_a.location.x + layout_a.size.width, layout_b.location.x); } diff --git a/tests/serde.rs b/tests/serde.rs index 19b70de37..14b9bdaac 100644 --- a/tests/serde.rs +++ b/tests/serde.rs @@ -14,7 +14,7 @@ mod serde { #[test] fn serde_can_deserialize_partial_values() { use serde_json; - let json = r###"{ + let json = r#"{ "inset": { "left": { "Length": 22 }, "right": "Auto" @@ -49,7 +49,7 @@ mod serde { }, "grid_row": { "start": "Auto" }, "grid_column": { "end": "Auto" } - }"###; - let _: Value = serde_json::from_str(&json).unwrap(); + }"#; + serde_json::from_str::(json).unwrap(); } }