dioxus/packages/core/examples/props.rs

21 lines
414 B
Rust
Raw Normal View History

use dioxus_core_macro::Props;
2021-02-21 02:59:16 +00:00
#[derive(Debug, 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
}
// have we committed to the trait style yet?
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
let r = g.b.unwrap_or_else(|| 10);
2021-02-21 02:59:16 +00:00
}
fn auto_into_some() {}