Feat: clean up code

This commit is contained in:
Jonathan Kelley committed 2021-02-24 01:32:50 -05:00
1 parent 5204862bc2
commit 83451372aa
16 files changed
+67 -72

No files matched your search

+14 -14
View File
@@ -1,10 +1,10 @@
//! An alternative function syntax
//!
use std::marker::PhantomData;
use bumpalo::Bump;
use dioxus_core::prelude::{DomTree, VNode};
use dioxus_core::prelude::{VNode};
fn main() {}
@@ -13,7 +13,7 @@ struct Context2<'a, P> {
rops: &'a P, // _p: PhantomData<&'a ()>,
}
impl<'a, P> Context2<'a, P> {
fn view(self, f: impl FnOnce(&'a Bump) -> VNode<'a>) -> DTree {
fn view(self, _f: impl FnOnce(&'a Bump) -> VNode<'a>) -> DTree {
DTree {}
}
@@ -23,9 +23,9 @@ impl<'a, P> Context2<'a, P> {
pub fn use_hook<'scope, InternalHookState: 'static, Output: 'a>(
&'scope self,
initializer: impl FnOnce() -> InternalHookState,
runner: impl FnOnce(&'a mut InternalHookState) -> Output,
cleanup: impl FnOnce(InternalHookState),
_initializer: impl FnOnce() -> InternalHookState,
_runner: impl FnOnce(&'a mut InternalHookState) -> Output,
_cleanup: impl FnOnce(InternalHookState),
) -> Output {
todo!()
}
@@ -35,7 +35,7 @@ trait Properties {}
struct DTree;
// type FC2<'a, T: 'a> = fn(Context2<T>) -> DTree;
fn virtual_child<'a, T: 'a>(bump: &'a Bump, props: T, f: FC2<T>) -> VNode<'a> {
fn virtual_child<'a, T: 'a>(_bump: &'a Bump, _props: T, _f: FC2<T>) -> VNode<'a> {
todo!()
}
@@ -56,7 +56,7 @@ fn Example(ctx: Context2<Props>) -> DTree {
}
// #[fc]
fn Example2(ctx: Context2<()>, name: &str, blah: &str) -> DTree {
fn Example2(ctx: Context2<()>, name: &str, _blah: &str) -> DTree {
let val = use_state(&ctx, || String::from("asd"));
ctx.view(move |b| {
@@ -67,10 +67,10 @@ fn Example2(ctx: Context2<()>, name: &str, blah: &str) -> DTree {
})
}
type FC2<'a, T: 'a> = fn(Context2<T>) -> DTree;
type FC2<'a, T> = fn(Context2<T>) -> DTree;
// still works if you don't take any references in your props (ie, something copy or cloneable)
static CHILD: FC2<Props2> = |ctx: Context2<Props2>| {
static CHILD: FC2<Props2> = |_ctx: Context2<Props2>| {
//
todo!()
};
@@ -81,15 +81,15 @@ struct Props2<'a> {
impl Properties for Props2<'_> {}
fn AltChild(ctx: Context2<Props2>) -> DTree {
ctx.view(|b| {
ctx.view(|_b| {
//
todo!()
})
}
fn use_state<'a, 'c, P, T: 'static, F: FnOnce() -> T>(
ctx: &'_ Context2<'a, P>,
initial_state_fn: F,
) -> (&'a T) {
_ctx: &'_ Context2<'a, P>,
_initial_state_fn: F,
) -> &'a T {
todo!()
}
+1 -1
View File
@@ -38,6 +38,6 @@ struct ChildProps<'a> {
item: &'a ListItem,
}
fn child_item(ctx: Context, props: &ChildProps) -> DomTree {
fn child_item(_ctx: Context, _props: &ChildProps) -> DomTree {
todo!()
}
+2 -2
View File
@@ -1,6 +1,6 @@
use std::{borrow::Borrow, marker::PhantomData, ops::Deref};
use builder::{button, div};
use builder::{button};
use dioxus_core::prelude::*;
fn main() {}
+6 -6
View File
@@ -4,7 +4,7 @@
// use dioxus_core::prelude::VNode;
// use dioxus_core::prelude::*;
// use once_cell::sync::{Lazy, OnceCell};
use std::{collections::HashMap, future::Future, marker::PhantomData};
use std::ops::Deref;
@@ -49,14 +49,14 @@ struct Context<'a> {
}
impl<'a> Context<'a> {
fn use_context<'b, I, O: 'b>(&self, f: fn(&'b I) -> O) -> ContextGuard2<O> {
fn use_context<'b, I, O: 'b>(&self, _f: fn(&'b I) -> O) -> ContextGuard2<O> {
todo!()
}
fn add_listener(&self, f: impl Fn(()) + 'a) {
fn add_listener(&self, _f: impl Fn(()) + 'a) {
todo!()
}
fn view(self, f: impl FnOnce(&'a String) + 'a) {}
fn view(self, _f: impl FnOnce(&'a String) + 'a) {}
// fn view(self, f: impl for<'b> FnOnce(&'a String) + 'a) {}
// fn view(self, f: impl for<'b> FnOnce(&'b String) + 'a) {}
}
@@ -77,7 +77,7 @@ fn t<'a>(ctx: Context<'a>) {
ctx.add_listener(move |_| {
// let val = value.get().as_str();
let val2 = r2.as_bytes();
let _val2 = r2.as_bytes();
println!("v2 is {}", r2);
// println!("refed is {}", refed);
});
@@ -97,7 +97,7 @@ fn t<'a>(ctx: Context<'a>) {
// let val2 = refed.as_bytes();
});
ctx.view(move |b| {});
ctx.view(move |_b| {});
}
fn main() {}
+1 -1
View File
@@ -25,7 +25,7 @@ struct OutputNode<'a> {
// everything is managed at runtime because that's how we make something ergonomc
// lifetime management in dioxus is just cheating around the rules
// our kind god manages lifetimes for us so we don't have to, thanks god
fn something<'s>(props: &'s SomeProps<'s>) -> OutputNode<'s> {
fn something<'s>(_props: &'s SomeProps<'s>) -> OutputNode<'s> {
todo!()
}
+2 -2
View File
@@ -10,7 +10,7 @@ use dioxus_core::prelude::*;
fn main() -> Result<(), ()> {
let p1 = Props { name: "bob".into() };
let mut vdom = VirtualDom::new_with_props(Example, p1);
let _vdom = VirtualDom::new_with_props(Example, p1);
// vdom.progress()?;
Ok(())
@@ -29,7 +29,7 @@ struct Props {
// // }
// }
static Example: FC<Props> = |ctx, props| {
static Example: FC<Props> = |ctx, _props| {
ctx.view(html! {
<div>
<h1> "hello world!" </h1>