gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81414 Sutichaykuna

⎇ d8c8bb472833ba92d694a9420e4c5bd8308e32e3 benches/generated/flex_grow_root_minimized.rs Rust · 49 siq'ikuna · 1.9 KB Ñawpa willay Pi imata llamkarqan ch'uya

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 node00 = taffy
6        .new_with_children(
7            taffy::style::Style {
8                flex_grow: 1f32,
9                flex_basis: taffy::style::Dimension::Points(200f32),
10                ..Default::default()
11            },
12            &[],
13        )
14        .unwrap();
15    let node01 = taffy
16        .new_with_children(
17            taffy::style::Style {
18                size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() },
19                ..Default::default()
20            },
21            &[],
22        )
23        .unwrap();
24    let node0 = taffy
25        .new_with_children(
26            taffy::style::Style {
27                flex_direction: taffy::style::FlexDirection::Column,
28                flex_grow: 1f32,
29                min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() },
30                max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(500f32), ..Size::auto() },
31                ..Default::default()
32            },
33            &[node00, node01],
34        )
35        .unwrap();
36    let node = taffy
37        .new_with_children(
38            taffy::style::Style {
39                flex_direction: taffy::style::FlexDirection::Column,
40                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() },
41                min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() },
42                max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(500f32), ..Size::auto() },
43                ..Default::default()
44            },
45            &[node0],
46        )
47        .unwrap();
48    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
49}