dioxus/packages/core/examples/step.rs

42 lines
748 B
Rust
Raw Normal View History

2021-03-14 00:11:06 +00:00
use dioxus_core::debug_renderer::DebugRenderer;
use dioxus_core::{component::Properties, prelude::*};
2021-02-07 21:21:38 +00:00
2021-02-07 22:38:17 +00:00
fn main() -> Result<(), ()> {
let p1 = SomeProps { name: "bob".into() };
2021-02-07 21:21:38 +00:00
2021-03-14 00:11:06 +00:00
let _vdom = DebugRenderer::new_with_props(Example, p1);
2021-02-07 22:38:17 +00:00
Ok(())
2021-02-07 21:21:38 +00:00
}
#[derive(Debug, PartialEq, Props)]
struct SomeProps {
2021-02-07 21:21:38 +00:00
name: String,
}
2021-02-12 05:29:46 +00:00
static Example: FC<SomeProps> = |ctx| {
2021-03-01 02:21:17 +00:00
ctx.render(html! {
2021-02-07 21:21:38 +00:00
<div>
2021-02-12 05:29:46 +00:00
<h1> "hello world!" </h1>
2021-02-07 21:21:38 +00:00
</div>
})
};
// #[test]
#[derive(PartialEq, Clone)]
struct MyStruct {
a: String,
}
fn check_before_to_owned() {
let new_str = MyStruct {
a: "asd".to_string(),
};
let out = town(&new_str);
}
fn town<T: ToOwned + PartialEq>(t: &T) -> T::Owned {
t.to_owned()
}