fix: messed up how lifetimes worked, need to render once per component

This commit is contained in:
Jonathan Kelley committed 2021-10-29 21:43:21 -04:00
1 parent 0e9d5fc530
commit ba9e1dbb8f
33 files changed
+323 -184

No files matched your search

+6 -3
View File
@@ -32,7 +32,7 @@ use std::{any::TypeId, ops::Deref, rc::Rc};
/// }
/// ```
pub struct Context<'src> {
pub scope: &'src Scope,
pub scope: &'src ScopeInner,
}
impl<'src> Copy for Context<'src> {}
@@ -45,7 +45,7 @@ impl<'src> Clone for Context<'src> {
// We currently deref to props, but it might make more sense to deref to Scope?
// This allows for code that takes cx.xyz instead of cx.props.xyz
impl<'a> Deref for Context<'a> {
type Target = &'a Scope;
type Target = &'a ScopeInner;
fn deref(&self) -> &Self::Target {
&self.scope
}
@@ -137,7 +137,10 @@ impl<'src> Context<'src> {
/// cx.render(lazy_tree)
/// }
///```
pub fn render(self, lazy_nodes: LazyNodes<'src>) -> Option<VNode<'src>> {
pub fn render<F: FnOnce(NodeFactory<'src>) -> VNode<'src>>(
self,
lazy_nodes: LazyNodes<'src, F>,
) -> Option<VNode<'src>> {
let bump = &self.scope.frames.wip_frame().bump;
Some(lazy_nodes.into_vnode(NodeFactory { bump }))
}