feat: massage lifetimes

This commit is contained in:
Jonathan Kelley committed 2021-10-16 17:37:28 -04:00
1 parent 16dbf4a6f8
commit 9726a065b0
92 files changed
+250 -241

No files matched your search

+3 -3
View File
@@ -3,7 +3,7 @@ use dioxus_core as dioxus;
use dioxus_core_macro::*;
use dioxus_html as dioxus_elements;
static Parent: FC<()> = |cx, props| {
static Parent: FC<()> = |(cx, props)| {
let value = cx.use_hook(|_| String::new(), |f| &*f, |_| {});
cx.render(rsx! {
@@ -21,7 +21,7 @@ struct ChildProps<'a> {
name: &'a String,
}
fn Child<'a>(cx: Context<'a>, props: &'a ChildProps) -> DomTree<'a> {
fn Child<'a>((cx, props): Component<'a, ChildProps>) -> DomTree<'a> {
cx.render(rsx! {
div {
h1 { "it's nested" }
@@ -35,7 +35,7 @@ struct Grandchild<'a> {
name: &'a String,
}
fn Child2<'a>(cx: Context<'a>, props: &Grandchild) -> DomTree<'a> {
fn Child2<'a>((cx, props): Component<'a, Grandchild>) -> DomTree<'a> {
cx.render(rsx! {
div { "Hello {props.name}!" }
})
+9 -9
View File
@@ -19,7 +19,7 @@ fn new_dom<P: 'static + Send>(app: FC<P>, props: P) -> VirtualDom {
#[test]
fn test_original_diff() {
static APP: FC<()> = |cx, props| {
static APP: FC<()> = |(cx, props)| {
cx.render(rsx! {
div {
div {
@@ -55,7 +55,7 @@ fn test_original_diff() {
#[test]
fn create() {
static APP: FC<()> = |cx, props| {
static APP: FC<()> = |(cx, props)| {
cx.render(rsx! {
div {
div {
@@ -118,7 +118,7 @@ fn create() {
#[test]
fn create_list() {
static APP: FC<()> = |cx, props| {
static APP: FC<()> = |(cx, props)| {
cx.render(rsx! {
{(0..3).map(|f| rsx!{ div {
"hello"
@@ -167,7 +167,7 @@ fn create_list() {
#[test]
fn create_simple() {
static APP: FC<()> = |cx, props| {
static APP: FC<()> = |(cx, props)| {
cx.render(rsx! {
div {}
div {}
@@ -205,7 +205,7 @@ fn create_simple() {
}
#[test]
fn create_components() {
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
cx.render(rsx! {
Child { "abc1" }
Child { "abc2" }
@@ -213,7 +213,7 @@ fn create_components() {
})
};
static Child: FC<()> = |cx, props| {
static Child: FC<()> = |(cx, props)| {
cx.render(rsx! {
h1 {}
div { {cx.children()} }
@@ -266,7 +266,7 @@ fn create_components() {
}
#[test]
fn anchors() {
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
cx.render(rsx! {
{true.then(|| rsx!{ div { "hello" } })}
{false.then(|| rsx!{ div { "goodbye" } })}
@@ -295,13 +295,13 @@ fn anchors() {
#[test]
fn suspended() {
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
let val = use_suspense(
cx,
|| async {
//
},
|cx, _| cx.render(rsx! { "hi "}),
|cx, p| cx.render(rsx! { "hi "}),
);
cx.render(rsx! { {val} })
};
+2 -2
View File
@@ -16,7 +16,7 @@ const IS_LOGGING_ENABLED: bool = true;
#[test]
fn please_work() {
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
cx.render(rsx! {
div {
hidden: "true"
@@ -30,7 +30,7 @@ fn please_work() {
})
};
static Child: FC<()> = |cx, props| {
static Child: FC<()> = |(cx, props)| {
cx.render(rsx! {
div { "child" }
})
+1 -1
View File
@@ -8,7 +8,7 @@ use dioxus_html as dioxus_elements;
#[async_std::test]
async fn event_queue_works() {
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
cx.render(rsx! {
div { "hello world" }
})
+1 -1
View File
@@ -10,7 +10,7 @@ type Shared<T> = Rc<RefCell<T>>;
#[test]
fn sample_refs() {
// static App: FC<()> = |cx, props|{
// static App: FC<()> = |(cx, props)|{
// let div_ref = use_node_ref::<MyRef, _>(cx);
// cx.render(rsx! {
+1 -1
View File
@@ -20,7 +20,7 @@ fn manual_diffing() {
value: Shared<&'static str>,
}
static App: FC<AppProps> = |cx, props| {
static App: FC<AppProps> = |(cx, props)| {
let val = props.value.lock().unwrap();
cx.render(rsx! { div { "{val}" } })
};
+2 -2
View File
@@ -17,12 +17,12 @@ fn new_dom() -> TestDom {
fn shared_state_test() {
struct MySharedState(&'static str);
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
cx.provide_state(MySharedState("world!"));
rsx!(cx, Child {})
};
static Child: FC<()> = |cx, props| {
static Child: FC<()> = |(cx, props)| {
let shared = cx.consume_state::<MySharedState>()?;
rsx!(cx, "Hello, {shared.0}")
};
+7 -7
View File
@@ -15,7 +15,7 @@ use dioxus_html as dioxus_elements;
#[test]
fn app_runs() {
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
//
cx.render(rsx!( div{"hello"} ))
};
@@ -26,7 +26,7 @@ fn app_runs() {
#[test]
fn fragments_work() {
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
cx.render(rsx!(
div{"hello"}
div{"goodbye"}
@@ -40,7 +40,7 @@ fn fragments_work() {
#[test]
fn lists_work() {
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
cx.render(rsx!(
h1 {"hello"}
{(0..6).map(|f| rsx!(span{ "{f}" }))}
@@ -53,7 +53,7 @@ fn lists_work() {
#[test]
fn conditional_rendering() {
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
cx.render(rsx!(
h1 {"hello"}
{true.then(|| rsx!(span{ "a" }))}
@@ -70,13 +70,13 @@ fn conditional_rendering() {
#[test]
fn child_components() {
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
cx.render(rsx!(
{true.then(|| rsx!(Child { }))}
{false.then(|| rsx!(Child { }))}
))
};
static Child: FC<()> = |cx, props| {
static Child: FC<()> = |(cx, props)| {
cx.render(rsx!(
h1 {"hello"}
h1 {"goodbye"}
@@ -89,7 +89,7 @@ fn child_components() {
#[test]
fn suspended_works() {
static App: FC<()> = |cx, props| {
static App: FC<()> = |(cx, props)| {
let title = use_suspense(cx, || async { "bob" }, |cx, f| cx.render(rsx! { "{f}"}));
cx.render(rsx!("hello" { title }))
};