chore: rollback some unecessary changes
This commit is contained in:
1 parent
e7e21fa2f0
commit
0dce3e03c8
6 files changed
+18
-18
No files matched your search
+2
-2
@@ -11,9 +11,9 @@ fn main() {
|
|||||||
fn app(cx: Scope) -> Element {
|
fn app(cx: Scope) -> Element {
|
||||||
let mut count = use_state(cx, || 0);
|
let mut count = use_state(cx, || 0);
|
||||||
|
|
||||||
render! {
|
cx.render(rsx! {
|
||||||
h1 { "High-Five counter: {count}" }
|
h1 { "High-Five counter: {count}" }
|
||||||
button { onclick: move |_| count += 1, "Up high!" }
|
button { onclick: move |_| count += 1, "Up high!" }
|
||||||
button { onclick: move |_| count -= 1, "Down low!" }
|
button { onclick: move |_| count -= 1, "Down low!" }
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
@@ -22,13 +22,13 @@ enum ShortOptimization {
|
|||||||
impl Buffer {
|
impl Buffer {
|
||||||
pub fn write_component(
|
pub fn write_component(
|
||||||
&mut self,
|
&mut self,
|
||||||
ComponentNode {
|
Component {
|
||||||
name,
|
name,
|
||||||
fields,
|
fields,
|
||||||
children,
|
children,
|
||||||
manual_props,
|
manual_props,
|
||||||
prop_gen_args,
|
prop_gen_args,
|
||||||
}: &ComponentNode,
|
}: &Component,
|
||||||
) -> Result {
|
) -> Result {
|
||||||
self.write_component_name(name, prop_gen_args)?;
|
self.write_component_name(name, prop_gen_args)?;
|
||||||
|
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ enum ShortOptimization {
|
|||||||
impl Buffer {
|
impl Buffer {
|
||||||
pub fn write_element(
|
pub fn write_element(
|
||||||
&mut self,
|
&mut self,
|
||||||
ElementNode {
|
Element {
|
||||||
name,
|
name,
|
||||||
key,
|
key,
|
||||||
attributes,
|
attributes,
|
||||||
children,
|
children,
|
||||||
_is_static,
|
_is_static,
|
||||||
}: &ElementNode,
|
}: &Element,
|
||||||
) -> Result {
|
) -> Result {
|
||||||
/*
|
/*
|
||||||
1. Write the tag
|
1. Write the tag
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ use syn::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
|
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
|
||||||
pub struct ComponentNode {
|
pub struct Component {
|
||||||
pub name: syn::Path,
|
pub name: syn::Path,
|
||||||
pub prop_gen_args: Option<AngleBracketedGenericArguments>,
|
pub prop_gen_args: Option<AngleBracketedGenericArguments>,
|
||||||
pub fields: Vec<ComponentField>,
|
pub fields: Vec<ComponentField>,
|
||||||
@@ -32,7 +32,7 @@ pub struct ComponentNode {
|
|||||||
pub manual_props: Option<Expr>,
|
pub manual_props: Option<Expr>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ComponentNode {
|
impl Component {
|
||||||
pub fn validate_component_path(path: &syn::Path) -> Result<()> {
|
pub fn validate_component_path(path: &syn::Path) -> Result<()> {
|
||||||
// ensure path segments doesn't have PathArguments, only the last
|
// ensure path segments doesn't have PathArguments, only the last
|
||||||
// segment is allowed to have one.
|
// segment is allowed to have one.
|
||||||
@@ -69,10 +69,10 @@ impl ComponentNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for ComponentNode {
|
impl Parse for Component {
|
||||||
fn parse(stream: ParseStream) -> Result<Self> {
|
fn parse(stream: ParseStream) -> Result<Self> {
|
||||||
let mut name = stream.parse::<syn::Path>()?;
|
let mut name = stream.parse::<syn::Path>()?;
|
||||||
ComponentNode::validate_component_path(&name)?;
|
Component::validate_component_path(&name)?;
|
||||||
|
|
||||||
// extract the path arguments from the path into prop_gen_args
|
// extract the path arguments from the path into prop_gen_args
|
||||||
let prop_gen_args = name.segments.last_mut().and_then(|seg| {
|
let prop_gen_args = name.segments.last_mut().and_then(|seg| {
|
||||||
@@ -124,7 +124,7 @@ impl Parse for ComponentNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToTokens for ComponentNode {
|
impl ToTokens for Component {
|
||||||
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
||||||
let name = &self.name;
|
let name = &self.name;
|
||||||
let prop_gen_args = &self.prop_gen_args;
|
let prop_gen_args = &self.prop_gen_args;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use syn::{
|
|||||||
// Parse the VNode::Element type
|
// Parse the VNode::Element type
|
||||||
// =======================================
|
// =======================================
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
|
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
|
||||||
pub struct ElementNode {
|
pub struct Element {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub key: Option<IfmtInput>,
|
pub key: Option<IfmtInput>,
|
||||||
pub attributes: Vec<ElementAttrNamed>,
|
pub attributes: Vec<ElementAttrNamed>,
|
||||||
@@ -19,7 +19,7 @@ pub struct ElementNode {
|
|||||||
pub _is_static: bool,
|
pub _is_static: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for ElementNode {
|
impl Parse for Element {
|
||||||
fn parse(stream: ParseStream) -> Result<Self> {
|
fn parse(stream: ParseStream) -> Result<Self> {
|
||||||
let el_name = Ident::parse(stream)?;
|
let el_name = Ident::parse(stream)?;
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ impl Parse for ElementNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToTokens for ElementNode {
|
impl ToTokens for Element {
|
||||||
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
||||||
let name = &self.name;
|
let name = &self.name;
|
||||||
let children = &self.children;
|
let children = &self.children;
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ Parse
|
|||||||
*/
|
*/
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
|
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
|
||||||
pub enum BodyNode {
|
pub enum BodyNode {
|
||||||
Element(ElementNode),
|
Element(Element),
|
||||||
Component(ComponentNode),
|
Component(Component),
|
||||||
ForLoop(ForLoop),
|
ForLoop(ForLoop),
|
||||||
IfChain(ExprIf),
|
IfChain(ExprIf),
|
||||||
Text(IfmtInput),
|
Text(IfmtInput),
|
||||||
@@ -71,7 +71,7 @@ impl Parse for BodyNode {
|
|||||||
&& first_char.is_ascii_lowercase()
|
&& first_char.is_ascii_lowercase()
|
||||||
&& !el_name.contains('_')
|
&& !el_name.contains('_')
|
||||||
{
|
{
|
||||||
return Ok(BodyNode::Element(stream.parse::<ElementNode>()?));
|
return Ok(BodyNode::Element(stream.parse::<Element>()?));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ impl Parse for BodyNode {
|
|||||||
// Input::<InputProps<'_, i32> {}
|
// Input::<InputProps<'_, i32> {}
|
||||||
// crate::Input::<InputProps<'_, i32> {}
|
// crate::Input::<InputProps<'_, i32> {}
|
||||||
if body_stream.peek(token::Brace) {
|
if body_stream.peek(token::Brace) {
|
||||||
ComponentNode::validate_component_path(&path)?;
|
Component::validate_component_path(&path)?;
|
||||||
return Ok(BodyNode::Component(stream.parse()?));
|
return Ok(BodyNode::Component(stream.parse()?));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user