浏览代码

chore: make clippy happy

Jonathan Kelley 2 年之前
父节点
当前提交
5a0ae67ccb

+ 3 - 3
packages/core/src/arena.rs

@@ -96,9 +96,9 @@ impl VirtualDom {
         node.clear_listeners();
         node.dynamic_nodes.iter().for_each(|node| match node {
             DynamicNode::Component(c) => self.drop_scope(c.scope.get().unwrap()),
-            DynamicNode::Fragment(nodes) => nodes
-                .into_iter()
-                .for_each(|node| self.drop_scope_inner(node)),
+            DynamicNode::Fragment(nodes) => {
+                nodes.iter().for_each(|node| self.drop_scope_inner(node))
+            }
             DynamicNode::Placeholder(t) => {
                 self.try_reclaim(t.get());
             }

+ 2 - 6
packages/core/src/diff.rs

@@ -52,12 +52,8 @@ impl<'b> VirtualDom {
         self.scope_stack.pop();
     }
 
-    fn diff_ok_to_err(&mut self, _l: &'b VNode<'b>, _e: &anyhow::Error) {
-        return;
-    }
-    fn diff_err_to_ok(&mut self, _e: &anyhow::Error, _l: &'b VNode<'b>) {
-        return;
-    }
+    fn diff_ok_to_err(&mut self, _l: &'b VNode<'b>, _e: &anyhow::Error) {}
+    fn diff_err_to_ok(&mut self, _e: &anyhow::Error, _l: &'b VNode<'b>) {}
 
     fn diff_node(&mut self, left_template: &'b VNode<'b>, right_template: &'b VNode<'b>) {
         if left_template.template.name != right_template.template.name {

+ 2 - 2
packages/core/src/fragment.rs

@@ -29,8 +29,8 @@ use crate::innerlude::*;
 pub fn Fragment<'a>(cx: Scope<'a, FragmentProps<'a>>) -> Element {
     let children = cx.props.0.as_ref().map_err(|e| anyhow::anyhow!("{}", e))?;
     Ok(VNode {
-        key: children.key.clone(),
-        parent: children.parent.clone(),
+        key: children.key,
+        parent: children.parent,
         template: children.template,
         root_ids: children.root_ids,
         dynamic_nodes: children.dynamic_nodes,

+ 1 - 1
packages/core/src/scheduler/wait.rs

@@ -34,7 +34,7 @@ impl VirtualDom {
         }
     }
 
-    pub(crate) fn acquire_suspense_boundary<'a>(&'a self, id: ScopeId) -> Rc<SuspenseContext> {
+    pub(crate) fn acquire_suspense_boundary(&self, id: ScopeId) -> Rc<SuspenseContext> {
         self.scopes[id.0]
             .consume_context::<Rc<SuspenseContext>>()
             .unwrap()

+ 2 - 2
packages/core/src/virtual_dom.rs

@@ -530,11 +530,11 @@ impl VirtualDom {
 
                 self.mutations
                     .templates
-                    .extend(context.mutations.borrow_mut().templates.drain(..));
+                    .append(&mut context.mutations.borrow_mut().templates);
 
                 self.mutations
                     .edits
-                    .extend(context.mutations.borrow_mut().edits.drain(..));
+                    .append(&mut context.mutations.borrow_mut().edits);
 
                 // TODO: count how many nodes are on the stack?
                 self.mutations.push(Mutation::ReplaceWith {

+ 18 - 6
packages/ssr/src/cache.rs

@@ -70,7 +70,7 @@ impl StringCache {
                         }
                     }
                 }
-                if children.len() == 0 && tag_is_self_closing(tag) {
+                if children.is_empty() && tag_is_self_closing(tag) {
                     write!(chain, "/>")?;
                 } else {
                     write!(chain, ">")?;
@@ -92,9 +92,21 @@ impl StringCache {
 }
 
 fn tag_is_self_closing(tag: &str) -> bool {
-    match tag {
-        "area" | "base" | "br" | "col" | "embed" | "hr" | "img" | "input" | "link" | "meta"
-        | "param" | "source" | "track" | "wbr" => true,
-        _ => false,
-    }
+    matches!(
+        tag,
+        "area"
+            | "base"
+            | "br"
+            | "col"
+            | "embed"
+            | "hr"
+            | "img"
+            | "input"
+            | "link"
+            | "meta"
+            | "param"
+            | "source"
+            | "track"
+            | "wbr"
+    )
 }

+ 1 - 1
packages/ssr/src/lib.rs

@@ -12,7 +12,7 @@ use crate::renderer::Renderer;
 /// A convenience function to render an `rsx!` call to a string
 ///
 /// For advanced rendering, create a new `SsrRender`.
-pub fn render_lazy<'a, 'b>(f: LazyNodes<'a, 'b>) -> String {
+pub fn render_lazy(f: LazyNodes<'_, '_>) -> String {
     // We need to somehow get the lazy call into the virtualdom even with the lifetime
     // Since the lazy lifetime is valid for this function, we can just transmute it to static temporarily
     // This is okay since we're returning an owned value