#![allow(unused)]
//! Example of components in
use std::{borrow::Borrow, marker::PhantomData};
use dioxus_core::prelude::*;
fn main() {}
static Header: FC<()> = |ctx, props| {
let inner = use_ref(&ctx, || 0);
let handler1 = move || println!("Value is {}", inner.borrow());
ctx.render(dioxus::prelude::LazyNodes::new(|nodectx| {
builder::ElementBuilder::new(nodectx, "div")
.child(VNode::Component(VComponent::new(
Bottom,
nodectx.bump().alloc(()),
None,
)))
.finish()
}))
};
static Bottom: FC<()> = |ctx, props| {
ctx.render(html! {
"bruh 1"
"bruh 2"
})
};
fn Top(ctx: Context, a: &str, b: &i32, c: &impl Fn()) -> DomTree {
ctx.render(html! {
"bruh 1"
"bruh 2"
})
}
struct Callback(Box);
// impl O> From for Callback {
// fn from(_: T) -> Self {
// todo!()
// }
// }
impl From<&dyn Fn(A) -> O> for Callback<&dyn Fn(A) -> O> {
fn from(_: &dyn Fn(A) -> O) -> Self {
todo!()
}
}
impl From<&dyn Fn(A, B) -> O> for Callback<&dyn Fn(A, B) -> O> {
fn from(_: &dyn Fn(A, B) -> O) -> Self {
todo!()
}
}
// compile time reordering of arguments
// Allows for transparently calling
#[derive(Default)]
pub struct Args {
pub a: CuOpt,
pub b: CuOpt,
pub c: CuOpt,
}
pub enum CuOpt {
Some(T),
None,
}
impl Default for CuOpt {
fn default() -> Self {
CuOpt::None
}
}
impl CuOpt {
fn unwrap(self) -> T {
match self {
CuOpt::Some(t) => t,
CuOpt::None => panic!(""),
}
}
}
trait IsMemo {
fn memo(&self, other: &Self) -> bool {
false
}
}
impl IsMemo for CuOpt {
fn memo(&self, other: &Self) -> bool {
self == other
}
}
impl PartialEq for CuOpt {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(CuOpt::Some(a), CuOpt::Some(b)) => a == b,
(CuOpt::Some(_), CuOpt::None) => false,
(CuOpt::None, CuOpt::Some(_)) => false,
(CuOpt::None, CuOpt::None) => true,
}
}
}
impl IsMemo for &CuOpt {
fn memo(&self, other: &Self) -> bool {
false
}
}
// #[test]
#[test]
fn try_test() {
// test_poc()
}
fn test_poc(ctx: Context) {
let b = Bump::new();
let h = Args {
a: CuOpt::Some("ASD"),
b: CuOpt::Some(123),
c: CuOpt::Some(|| {}),
// c: CuOpt::Some(b.alloc(|| {})),
// c: CuOpt::Some(Box::new(|| {}) as Box),
};
let h2 = Args {
a: CuOpt::Some("ASD"),
b: CuOpt::Some(123),
c: CuOpt::Some(|| {}),
// c: CuOpt::Some(b.alloc(|| {})),
// c: CuOpt::Some(Box::new(|| {}) as Box),
// c: CuOpt::Some(Box::new(|| {}) as Box),
// c: CuOpt::Some(Box::new(|| {}) as Box),
};
// dbg!((&h.a).memo((&&h2.a)));
// dbg!((&h.b).memo((&&h2.b)));
// dbg!((&h.c).memo((&&h2.c)));
//
// ctx: Context
Top(ctx, &h.a.unwrap(), &h.b.unwrap(), &h.c.unwrap());
}
fn test_realzies() {
let h = Args {
a: CuOpt::Some("ASD"),
b: CuOpt::Some(123),
c: CuOpt::Some(|| {}),
};
let g = |ctx: Context| {
//
Top(ctx, &h.a.unwrap(), &h.b.unwrap(), &h.c.unwrap())
};
}