fix clippy issues

This commit is contained in:
Michael Zhang 2020-02-09 22:58:13 -06:00
parent ebcb5f818b
commit 46be78e007
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
3 changed files with 22 additions and 22 deletions

View file

@ -9,7 +9,6 @@ mod visitor;
use std::collections::HashMap;
use petgraph::{dot::Dot, graph::Graph};
use proc_macro2::TokenStream;
use syn::Expr;
@ -29,10 +28,8 @@ fn process(
let new_dom = visitor.make_graph(&dom);
let toplevel_names = visitor.gen_code(&new_dom);
// println!("{:?}", visitor);
println!("DOT:");
let graph: Graph<_, _, _> = visitor.deps.clone().into_graph();
println!("{:?}", Dot::new(&graph));
// let graph: Graph<_, _, _> = visitor.deps.clone().into_graph();
// println!("{:?}", Dot::new(&graph));
let name = format_ident!("{}", name);
let mut model = TokenStream::new();
@ -85,7 +82,7 @@ fn process(
}
#[proc_macro]
pub fn example(input_tokens: proc_macro::TokenStream) -> proc_macro::TokenStream {
pub fn example(_input_tokens: proc_macro::TokenStream) -> proc_macro::TokenStream {
let helloworld_datamodel: HashMap<String, String> = hashmap! {
"name".into() => "String".into(),
};

View file

@ -15,8 +15,10 @@ type Id = Symbol;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum TagLhs {
Bind(String),
On(String),
Plain(String),
// On(String),
// Plain(String),
#[doc(hidden)]
_Nonexhaustive,
}
#[derive(Debug, Default)]
@ -31,6 +33,9 @@ pub enum Rsx {
Elem(Elem<Rsx>),
Code(Expr),
Text(String),
#[doc(hidden)]
_Nonexhaustive,
}
#[derive(Debug)]
@ -38,12 +43,16 @@ pub enum TaggedRsx {
Elem(Id, Elem<TaggedRsx>),
Code(Id, Expr),
Text(Id, String),
#[doc(hidden)]
_Nonexhaustive,
}
impl TaggedRsx {
pub fn get_id(&self) -> Id {
match self {
TaggedRsx::Elem(id, _) | TaggedRsx::Code(id, _) | TaggedRsx::Text(id, _) => *id,
_ => unimplemented!(),
}
}
}
@ -60,11 +69,6 @@ pub enum DepNode {
ModelValue(Symbol),
}
#[derive(Debug)]
enum DepActions {
Updates,
}
type DependencyGraph = DiGraphMap<DepNode, ()>;
#[derive(Default, Debug)]
@ -138,6 +142,7 @@ impl Visitor {
TaggedRsx::Code(node_id, expr.clone())
}
Rsx::Text(literal) => TaggedRsx::Text(node_id, literal.clone()),
_ => unimplemented!(),
};
new_nodes.push(new_node);
}
@ -150,7 +155,7 @@ impl Visitor {
let node_str = node.get_id().as_str();
let make_node_id = format_ident!("make_{}", node_str);
match node {
TaggedRsx::Elem(node_id, Elem { tag, attrs, inner }) => {
TaggedRsx::Elem(node_id, Elem { tag, inner, .. }) => {
let mut updates = TokenStream::new();
if let Some(this_attrs) = self.elem_attr_map.get(node_id) {
for attr in this_attrs {
@ -159,7 +164,6 @@ impl Visitor {
let mut update_func = TokenStream::new();
while let Some(nx) = dfs.next(&self.deps) {
if nx != starting {
println!("NX: {:?}", nx);
match nx {
DepNode::ModelValue(sym) => {
let sym_name = format_ident!(
@ -206,24 +210,24 @@ impl Visitor {
self.impl_code.extend(quote! {
fn #make_node_id(&self) -> impl stdweb::web::INode {
let el = document().create_element(#tag).unwrap();
el.set_attribute("id", #node_str);
el.set_attribute("id", #node_str).unwrap();
#updates
el
}
});
self.gen_code(&inner);
}
TaggedRsx::Code(node_id, expr) => {
TaggedRsx::Code(_, _) => {
self.impl_code.extend(quote! {
#[inline]
fn #make_node_id(&self) -> impl stdweb::web::INode {
let el = document().create_element("span").expect("shouldn't fail");
el.set_attribute("id", #node_str);
el.set_attribute("id", #node_str).unwrap();
el
}
});
}
TaggedRsx::Text(node_id, literal) => {
TaggedRsx::Text(_, literal) => {
self.impl_code.extend(quote! {
#[inline]
fn #make_node_id(&self) -> impl stdweb::web::INode {
@ -231,7 +235,7 @@ impl Visitor {
}
});
}
_ => (),
_ => unimplemented!(),
}
names.push(format!("{}", make_node_id));
}

View file

@ -12,9 +12,8 @@ use stdweb::{
unstable::TryFrom,
web::{
document, html_element::InputElement, Element, IElement, IEventTarget, INode,
INonElementParentNode, TextNode,
INonElementParentNode,
},
Reference, Value,
};
use crate::backend::{Backend, Web};