chore: rollback some unecessary changes

This commit is contained in:
Jonathan Kelley 2022-12-23 18:08:23 -05:00
parent e7e21fa2f0
commit 0dce3e03c8
6 changed files with 18 additions and 18 deletions

View file

@ -11,9 +11,9 @@ fn main() {
fn app(cx: Scope) -> Element {
let mut count = use_state(cx, || 0);
render! {
cx.render(rsx! {
h1 { "High-Five counter: {count}" }
button { onclick: move |_| count += 1, "Up high!" }
button { onclick: move |_| count -= 1, "Down low!" }
}
})
}

View file

@ -22,13 +22,13 @@ enum ShortOptimization {
impl Buffer {
pub fn write_component(
&mut self,
ComponentNode {
Component {
name,
fields,
children,
manual_props,
prop_gen_args,
}: &ComponentNode,
}: &Component,
) -> Result {
self.write_component_name(name, prop_gen_args)?;

View file

@ -22,13 +22,13 @@ enum ShortOptimization {
impl Buffer {
pub fn write_element(
&mut self,
ElementNode {
Element {
name,
key,
attributes,
children,
_is_static,
}: &ElementNode,
}: &Element,
) -> Result {
/*
1. Write the tag

View file

@ -24,7 +24,7 @@ use syn::{
};
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
pub struct ComponentNode {
pub struct Component {
pub name: syn::Path,
pub prop_gen_args: Option<AngleBracketedGenericArguments>,
pub fields: Vec<ComponentField>,
@ -32,7 +32,7 @@ pub struct ComponentNode {
pub manual_props: Option<Expr>,
}
impl ComponentNode {
impl Component {
pub fn validate_component_path(path: &syn::Path) -> Result<()> {
// ensure path segments doesn't have PathArguments, only the last
// 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> {
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
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) {
let name = &self.name;
let prop_gen_args = &self.prop_gen_args;

View file

@ -11,7 +11,7 @@ use syn::{
// Parse the VNode::Element type
// =======================================
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
pub struct ElementNode {
pub struct Element {
pub name: Ident,
pub key: Option<IfmtInput>,
pub attributes: Vec<ElementAttrNamed>,
@ -19,7 +19,7 @@ pub struct ElementNode {
pub _is_static: bool,
}
impl Parse for ElementNode {
impl Parse for Element {
fn parse(stream: ParseStream) -> Result<Self> {
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) {
let name = &self.name;
let children = &self.children;

View file

@ -21,8 +21,8 @@ Parse
*/
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
pub enum BodyNode {
Element(ElementNode),
Component(ComponentNode),
Element(Element),
Component(Component),
ForLoop(ForLoop),
IfChain(ExprIf),
Text(IfmtInput),
@ -71,7 +71,7 @@ impl Parse for BodyNode {
&& first_char.is_ascii_lowercase()
&& !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> {}
// crate::Input::<InputProps<'_, i32> {}
if body_stream.peek(token::Brace) {
ComponentNode::validate_component_path(&path)?;
Component::validate_component_path(&path)?;
return Ok(BodyNode::Component(stream.parse()?));
}
}