props.rs 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. use std::marker::PhantomData;
  2. fn main() {}
  3. trait Props<'parent> {}
  4. struct SomeProps<'p> {
  5. text: &'p str,
  6. }
  7. impl<'p> Props<'p> for SomeProps<'p> {}
  8. struct OutputNode<'a> {
  9. _p: PhantomData<&'a ()>,
  10. }
  11. // combine reference to self (borrowed from self) and referenfce to parent (borrowed from parent)
  12. // borrow chain looks like 'p + 's -> 'p + 's -> 'p + 's
  13. // always adding new lifetimes from self into the mix
  14. // what does a "self" lifetime mean?
  15. // a "god" gives us our data
  16. // the god's lifetime is tied to Context, and the borrowed props object
  17. // for the sake of simplicity, we just clobber lifetimes.
  18. // user functions are just lies and we abuse lifetimes.
  19. // everything is managed at runtime because that's how we make something ergonomc
  20. // lifetime management in dioxus is just cheating around the rules
  21. // our kind god manages lifetimes for us so we don't have to, thanks god
  22. fn something<'s>(_props: &'s SomeProps<'s>) -> OutputNode<'s> {
  23. todo!()
  24. }
  25. // type BC<'p, P: Props<'p>> = for<'a, 'b, 'c> fn(&'a P<'b>) -> OutputNode<'c>;