gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81414 Definitions

⎇ d8c8bb472833ba92d694a9420e4c5bd8308e32e3 benches/generated/flex_grow_within_constrained_max_column.rs Rust · 36 lines · 1.2 KB History Who touched what raw

Strict types for style values (#269) 0d8c198a9 · Nico Burns ·

1pub fn compute() {
2    #[allow(unused_imports)]
3    use taffy::prelude::*;
4    let mut taffy = taffy::Taffy::new();
5    let node0 = taffy
6        .new_with_children(
7            taffy::style::Style {
8                flex_shrink: 1f32,
9                flex_basis: taffy::style::Dimension::Points(100f32),
10                ..Default::default()
11            },
12            &[],
13        )
14        .unwrap();
15    let node1 = taffy
16        .new_with_children(
17            taffy::style::Style {
18                size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() },
19                ..Default::default()
20            },
21            &[],
22        )
23        .unwrap();
24    let node = taffy
25        .new_with_children(
26            taffy::style::Style {
27                flex_direction: taffy::style::FlexDirection::Column,
28                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() },
29                max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() },
30                ..Default::default()
31            },
32            &[node0, node1],
33        )
34        .unwrap();
35    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
36}