dioxus/packages/core/examples/props.rs

17 lines
355 B
Rust
Raw Normal View History

use dioxus_core::prelude::*;
2021-02-21 02:59:16 +00:00
#[derive(Debug, PartialEq, Props)]
struct SomeProps {
a: i32,
2021-02-21 02:59:16 +00:00
// automatically do the default (none) and automatically Into<T>
#[builder(default, setter(strip_option))]
b: Option<i32>,
2021-02-21 02:59:16 +00:00
}
fn main() {
let g: SomeProps = SomeProps::builder().a(10).b(10).build();
2021-02-21 02:59:16 +00:00
2021-03-11 00:42:31 +00:00
let _r = g.b.unwrap_or_else(|| 10);
2021-02-21 02:59:16 +00:00
}