⎇ dfdb5a21fc84b657c51b185abe30c54c19fb89b6
examples/basic.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
added prelude + some refactoring
1use stretch::prelude::*;
2
3fn main() -> Result<(), Error> {
4 let mut stretch = Stretch::new();
5 let child = stretch.new_node(
6 Style { size: Size { width: Dimension::Percent(0.5), height: Dimension::Auto }, ..Default::default() },
7 &[],
8 )?;
9 let node = stretch.new_node(
10 Style {
11 size: Size { width: Dimension::Points(100.0), height: Dimension::Points(100.0) },
12 justify_content: JustifyContent::Center,
13 ..Default::default()
14 },
15 &[child],
16 )?;
17
18 stretch.compute_layout(node, Size::undefined())?;
19 println!("node: {:#?}", stretch.layout(node)?);
20 println!("child: {:#?}", stretch.layout(child)?);
21
22 Ok(())
23}