|
@@ -651,52 +651,52 @@ pub trait IntoDynNode<'a, A = ()> {
|
|
/// Consume this item along with a scopestate and produce a DynamicNode
|
|
/// Consume this item along with a scopestate and produce a DynamicNode
|
|
///
|
|
///
|
|
/// You can use the bump alloactor of the scopestate to creat the dynamic node
|
|
/// You can use the bump alloactor of the scopestate to creat the dynamic node
|
|
- fn into_vnode(self, cx: &'a ScopeState) -> DynamicNode<'a>;
|
|
|
|
|
|
+ fn into_dyn_node(self, cx: &'a ScopeState) -> DynamicNode<'a>;
|
|
}
|
|
}
|
|
|
|
|
|
impl<'a> IntoDynNode<'a> for () {
|
|
impl<'a> IntoDynNode<'a> for () {
|
|
- fn into_vnode(self, _cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
|
|
|
|
+ fn into_dyn_node(self, _cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
DynamicNode::default()
|
|
DynamicNode::default()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl<'a> IntoDynNode<'a> for VNode<'a> {
|
|
impl<'a> IntoDynNode<'a> for VNode<'a> {
|
|
- fn into_vnode(self, _cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
|
|
|
|
+ fn into_dyn_node(self, _cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
DynamicNode::Fragment(_cx.bump().alloc([self]))
|
|
DynamicNode::Fragment(_cx.bump().alloc([self]))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
impl<'a> IntoDynNode<'a> for DynamicNode<'a> {
|
|
impl<'a> IntoDynNode<'a> for DynamicNode<'a> {
|
|
- fn into_vnode(self, _cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
|
|
|
|
+ fn into_dyn_node(self, _cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
self
|
|
self
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
impl<'a, T: IntoDynNode<'a>> IntoDynNode<'a> for Option<T> {
|
|
impl<'a, T: IntoDynNode<'a>> IntoDynNode<'a> for Option<T> {
|
|
- fn into_vnode(self, _cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
|
|
|
|
+ fn into_dyn_node(self, _cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
match self {
|
|
match self {
|
|
- Some(val) => val.into_vnode(_cx),
|
|
|
|
|
|
+ Some(val) => val.into_dyn_node(_cx),
|
|
None => DynamicNode::default(),
|
|
None => DynamicNode::default(),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
impl<'a> IntoDynNode<'a> for &Element<'a> {
|
|
impl<'a> IntoDynNode<'a> for &Element<'a> {
|
|
- fn into_vnode(self, _cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
|
|
|
|
+ fn into_dyn_node(self, _cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
match self.as_ref() {
|
|
match self.as_ref() {
|
|
- Some(val) => val.clone().into_vnode(_cx),
|
|
|
|
|
|
+ Some(val) => val.clone().into_dyn_node(_cx),
|
|
_ => DynamicNode::default(),
|
|
_ => DynamicNode::default(),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
impl<'a, 'b> IntoDynNode<'a> for LazyNodes<'a, 'b> {
|
|
impl<'a, 'b> IntoDynNode<'a> for LazyNodes<'a, 'b> {
|
|
- fn into_vnode(self, cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
|
|
|
|
+ fn into_dyn_node(self, cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
DynamicNode::Fragment(cx.bump().alloc([cx.render(self).unwrap()]))
|
|
DynamicNode::Fragment(cx.bump().alloc([cx.render(self).unwrap()]))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
impl<'a, 'b> IntoDynNode<'b> for &'a str {
|
|
impl<'a, 'b> IntoDynNode<'b> for &'a str {
|
|
- fn into_vnode(self, cx: &'b ScopeState) -> DynamicNode<'b> {
|
|
|
|
|
|
+ fn into_dyn_node(self, cx: &'b ScopeState) -> DynamicNode<'b> {
|
|
DynamicNode::Text(VText {
|
|
DynamicNode::Text(VText {
|
|
value: cx.bump().alloc_str(self),
|
|
value: cx.bump().alloc_str(self),
|
|
id: Default::default(),
|
|
id: Default::default(),
|
|
@@ -705,7 +705,7 @@ impl<'a, 'b> IntoDynNode<'b> for &'a str {
|
|
}
|
|
}
|
|
|
|
|
|
impl IntoDynNode<'_> for String {
|
|
impl IntoDynNode<'_> for String {
|
|
- fn into_vnode(self, cx: &ScopeState) -> DynamicNode {
|
|
|
|
|
|
+ fn into_dyn_node(self, cx: &ScopeState) -> DynamicNode {
|
|
DynamicNode::Text(VText {
|
|
DynamicNode::Text(VText {
|
|
value: cx.bump().alloc(self),
|
|
value: cx.bump().alloc(self),
|
|
id: Default::default(),
|
|
id: Default::default(),
|
|
@@ -714,13 +714,13 @@ impl IntoDynNode<'_> for String {
|
|
}
|
|
}
|
|
|
|
|
|
impl<'b> IntoDynNode<'b> for Arguments<'_> {
|
|
impl<'b> IntoDynNode<'b> for Arguments<'_> {
|
|
- fn into_vnode(self, cx: &'b ScopeState) -> DynamicNode<'b> {
|
|
|
|
|
|
+ fn into_dyn_node(self, cx: &'b ScopeState) -> DynamicNode<'b> {
|
|
cx.text_node(self)
|
|
cx.text_node(self)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
impl<'a> IntoDynNode<'a> for &'a VNode<'a> {
|
|
impl<'a> IntoDynNode<'a> for &'a VNode<'a> {
|
|
- fn into_vnode(self, _cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
|
|
|
|
+ fn into_dyn_node(self, _cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
DynamicNode::Fragment(_cx.bump().alloc([VNode {
|
|
DynamicNode::Fragment(_cx.bump().alloc([VNode {
|
|
parent: self.parent,
|
|
parent: self.parent,
|
|
template: self.template.clone(),
|
|
template: self.template.clone(),
|
|
@@ -732,24 +732,24 @@ impl<'a> IntoDynNode<'a> for &'a VNode<'a> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-pub trait IntoTemplate<'a> {
|
|
|
|
- fn into_template(self, _cx: &'a ScopeState) -> VNode<'a>;
|
|
|
|
|
|
+pub trait IntoVNode<'a> {
|
|
|
|
+ fn into_vnode(self, _cx: &'a ScopeState) -> VNode<'a>;
|
|
}
|
|
}
|
|
-impl<'a> IntoTemplate<'a> for VNode<'a> {
|
|
|
|
- fn into_template(self, _cx: &'a ScopeState) -> VNode<'a> {
|
|
|
|
|
|
+impl<'a> IntoVNode<'a> for VNode<'a> {
|
|
|
|
+ fn into_vnode(self, _cx: &'a ScopeState) -> VNode<'a> {
|
|
self
|
|
self
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-impl<'a> IntoTemplate<'a> for Element<'a> {
|
|
|
|
- fn into_template(self, cx: &'a ScopeState) -> VNode<'a> {
|
|
|
|
|
|
+impl<'a> IntoVNode<'a> for Element<'a> {
|
|
|
|
+ fn into_vnode(self, cx: &'a ScopeState) -> VNode<'a> {
|
|
match self {
|
|
match self {
|
|
- Some(val) => val.into_template(cx),
|
|
|
|
|
|
+ Some(val) => val.into_vnode(cx),
|
|
_ => VNode::empty(cx).unwrap(),
|
|
_ => VNode::empty(cx).unwrap(),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-impl<'a, 'b> IntoTemplate<'a> for LazyNodes<'a, 'b> {
|
|
|
|
- fn into_template(self, cx: &'a ScopeState) -> VNode<'a> {
|
|
|
|
|
|
+impl<'a, 'b> IntoVNode<'a> for LazyNodes<'a, 'b> {
|
|
|
|
+ fn into_vnode(self, cx: &'a ScopeState) -> VNode<'a> {
|
|
cx.render(self).unwrap()
|
|
cx.render(self).unwrap()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -759,12 +759,12 @@ pub struct FromNodeIterator;
|
|
impl<'a, T, I> IntoDynNode<'a, FromNodeIterator> for T
|
|
impl<'a, T, I> IntoDynNode<'a, FromNodeIterator> for T
|
|
where
|
|
where
|
|
T: Iterator<Item = I>,
|
|
T: Iterator<Item = I>,
|
|
- I: IntoTemplate<'a>,
|
|
|
|
|
|
+ I: IntoVNode<'a>,
|
|
{
|
|
{
|
|
- fn into_vnode(self, cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
|
|
|
|
+ fn into_dyn_node(self, cx: &'a ScopeState) -> DynamicNode<'a> {
|
|
let mut nodes = bumpalo::collections::Vec::new_in(cx.bump());
|
|
let mut nodes = bumpalo::collections::Vec::new_in(cx.bump());
|
|
|
|
|
|
- nodes.extend(self.into_iter().map(|node| node.into_template(cx)));
|
|
|
|
|
|
+ nodes.extend(self.into_iter().map(|node| node.into_vnode(cx)));
|
|
|
|
|
|
match nodes.into_bump_slice() {
|
|
match nodes.into_bump_slice() {
|
|
children if children.is_empty() => DynamicNode::default(),
|
|
children if children.is_empty() => DynamicNode::default(),
|