alternative.rs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // //! An alternative function syntax
  2. // //!
  3. // use bumpalo::Bump;
  4. // use dioxus_core::prelude::VNode;
  5. fn main() {}
  6. // struct Context2<'a, P> {
  7. // _props: &'a P, // _p: PhantomData<&'a ()>,
  8. // rops: &'a P, // _p: PhantomData<&'a ()>,
  9. // }
  10. // impl<'a, P> Context2<'a, P> {
  11. // fn render(self, _f: impl FnOnce(&'a Bump) -> VNode<'a>) -> DTree {
  12. // DTree {}
  13. // }
  14. // fn props(&self) -> &'a P {
  15. // todo!()
  16. // }
  17. // pub fn use_hook<'scope, InternalHookState: 'static, Output: 'a>(
  18. // &'scope self,
  19. // _initializer: impl FnOnce() -> InternalHookState,
  20. // _runner: impl FnOnce(&'a mut InternalHookState) -> Output,
  21. // _cleanup: impl FnOnce(InternalHookState),
  22. // ) -> Output {
  23. // todo!()
  24. // }
  25. // }
  26. // trait Properties {}
  27. // struct DTree;
  28. // // type FC2<'a, T: 'a> = fn(Context2<T>) -> DTree;
  29. // fn virtual_child<'a, T: 'a>(_bump: &'a Bump, _props: T, _f: FC2<T>) -> VNode<'a> {
  30. // todo!()
  31. // }
  32. // struct Props {
  33. // c: String,
  34. // }
  35. // fn Example(ctx: Context2<Props>) -> DTree {
  36. // let val = use_state(&ctx, || String::from("asd"));
  37. // let props = ctx.props();
  38. // ctx.render(move |b| {
  39. // dioxus_core::nodebuilder::div(b)
  40. // .child(dioxus_core::nodebuilder::text(props.c.as_str()))
  41. // .child(virtual_child(b, Props2 { a: val }, AltChild))
  42. // .finish()
  43. // })
  44. // }
  45. // // #[fc]
  46. // fn Example2(ctx: Context2<()>, name: &str, _blah: &str) -> DTree {
  47. // let val = use_state(&ctx, || String::from("asd"));
  48. // ctx.render(move |ctx| {
  49. // dioxus_core::builder::ElementBuilder::new(b, "div")
  50. // .child(dioxus_core::nodebuilder::text(name))
  51. // .child(virtual_child(b, Props2 { a: val }, AltChild))
  52. // .finish()
  53. // })
  54. // }
  55. // type FC2<'a, T> = fn(Context2<T>) -> DTree;
  56. // // still works if you don't take any references in your props (ie, something copy or cloneable)
  57. // static CHILD: FC2<Props2> = |_ctx: Context2<Props2>| {
  58. // //
  59. // todo!()
  60. // };
  61. // struct Props2<'a> {
  62. // a: &'a String,
  63. // }
  64. // impl Properties for Props2<'_> {}
  65. // fn AltChild(ctx: Context2<Props2>) -> DTree {
  66. // ctx.render(|_b| {
  67. // //
  68. // todo!()
  69. // })
  70. // }
  71. // fn use_state<'a, 'c, P, T: 'static, F: FnOnce() -> T>(
  72. // _ctx: &'_ Context2<'a, P>,
  73. // _initial_state_fn: F,
  74. // ) -> &'a T {
  75. // todo!()
  76. // }