wip: move some examples around
This commit is contained in:
1 parent
cca7c5fc3a
commit
98a09339fd
70 files changed
+111
-117
No files matched your search
@@ -620,23 +620,17 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// impl IntoVNode<'_> for () {
|
||||
// fn into_vnode<'a>(self, cx: NodeFactory<'a>) -> VNode<'a> {
|
||||
// todo!();
|
||||
// VNode::Suspended {
|
||||
// real: Cell::new(RealDomNode::empty()),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
impl IntoVNode<'_> for () {
|
||||
fn into_vnode<'a>(self, cx: NodeFactory<'a>) -> VNode<'a> {
|
||||
cx.fragment_from_iter(None as Option<VNode>)
|
||||
}
|
||||
}
|
||||
|
||||
// impl IntoVNode<'_> for Option<()> {
|
||||
// fn into_vnode<'a>(self, cx: NodeFactory<'a>) -> VNode<'a> {
|
||||
// todo!();
|
||||
// VNode::Suspended {
|
||||
// real: Cell::new(RealDomNode::empty()),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
impl IntoVNode<'_> for Option<()> {
|
||||
fn into_vnode<'a>(self, cx: NodeFactory<'a>) -> VNode<'a> {
|
||||
cx.fragment_from_iter(None as Option<VNode>)
|
||||
}
|
||||
}
|
||||
|
||||
/// Construct a text VNode.
|
||||
///
|
||||
@@ -717,8 +711,6 @@ pub fn virtual_child<'a, T: Properties + 'a>(
|
||||
VNode::Component(
|
||||
cx.bump()
|
||||
.alloc(crate::nodes::VComponent::new(&cx, f, props, key, children)),
|
||||
// cx.bump()
|
||||
// .alloc(crate::nodes::VComponent::new(f, props, key)),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -786,6 +778,26 @@ impl<'a> NodeFactory<'a> {
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn virtual_child<T: Properties + 'a, C>(
|
||||
&self,
|
||||
f: FC<T>,
|
||||
props: T,
|
||||
key: Option<&'a str>, // key: NodeKey<'a>,
|
||||
children: C,
|
||||
) -> VNode<'a>
|
||||
where
|
||||
C: 'a + AsRef<[VNode<'a>]>,
|
||||
{
|
||||
let children: &'a C = self.bump().alloc(children);
|
||||
VNode::Component(self.bump().alloc(crate::nodes::VComponent::new(
|
||||
self,
|
||||
f,
|
||||
props,
|
||||
key,
|
||||
children.as_ref(),
|
||||
)))
|
||||
}
|
||||
|
||||
pub fn fragment_from_iter(
|
||||
self,
|
||||
node_iter: impl IntoIterator<Item = impl IntoVNode<'a>>,
|
||||
|
||||
Reference in new issue
Block a user