From 9d5f32ba9b18aecc81e719143c4c010336a9803a Mon Sep 17 00:00:00 2001 From: Samuel El-Borai Date: Sat, 22 Jan 2022 19:31:03 +0100 Subject: [PATCH] cargo clippy --fix -- --allow unused_braces - The '--allow unused_braces' is to avoid removing the extra curly braces used within html! macro calls. --- examples/dodrio/todomvc/src/controller.rs | 4 ++-- examples/dodrio/todomvc/src/todo.rs | 2 +- examples/dodrio/todomvc/src/todos.rs | 4 ++-- macros/src/error.rs | 6 +++--- macros/src/html.rs | 2 +- macros/src/span.rs | 4 ++-- typed-html/src/output/stdweb.rs | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/dodrio/todomvc/src/controller.rs b/examples/dodrio/todomvc/src/controller.rs index a347afa..112905c 100644 --- a/examples/dodrio/todomvc/src/controller.rs +++ b/examples/dodrio/todomvc/src/controller.rs @@ -129,12 +129,12 @@ impl Deref for AutoCommitTodos<'_> { type Target = Todos; fn deref(&self) -> &Todos { - &self.todos + self.todos } } impl DerefMut for AutoCommitTodos<'_> { fn deref_mut(&mut self) -> &mut Todos { - &mut self.todos + self.todos } } diff --git a/examples/dodrio/todomvc/src/todo.rs b/examples/dodrio/todomvc/src/todo.rs index c8901c4..8fad884 100644 --- a/examples/dodrio/todomvc/src/todo.rs +++ b/examples/dodrio/todomvc/src/todo.rs @@ -1,7 +1,7 @@ //! Type definition and `dodrio::Render` implementation for a single todo item. use crate::keys; -use dodrio::{bumpalo::Bump, Node, Render, RenderContext, RootRender, VdomWeak}; +use dodrio::{Node, Render, RenderContext, RootRender, VdomWeak}; use serde::{Deserialize, Serialize}; use std::marker::PhantomData; use typed_html::dodrio; diff --git a/examples/dodrio/todomvc/src/todos.rs b/examples/dodrio/todomvc/src/todos.rs index dd09a43..493c760 100644 --- a/examples/dodrio/todomvc/src/todos.rs +++ b/examples/dodrio/todomvc/src/todos.rs @@ -13,7 +13,7 @@ use dodrio::{ }; use serde::{Deserialize, Serialize}; use std::marker::PhantomData; -use std::mem; + use typed_html::dodrio; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; @@ -123,7 +123,7 @@ impl Todos { /// Take the current draft text and replace it with an empty string. pub fn take_draft(&mut self) -> String { - mem::replace(&mut self.draft, String::new()) + std::mem::take(&mut self.draft) } /// Get the current visibility for these todos. diff --git a/macros/src/error.rs b/macros/src/error.rs index 06afd41..5b0d758 100644 --- a/macros/src/error.rs +++ b/macros/src/error.rs @@ -21,7 +21,7 @@ fn pprint_token(token: &str) -> &str { } fn pprint_tokens(tokens: &[String]) -> String { - let tokens: Vec<&str> = tokens.iter().map(|s| pprint_token(&s)).collect(); + let tokens: Vec<&str> = tokens.iter().map(|s| pprint_token(s)).collect(); if tokens.len() > 1 { let start = tokens[..tokens.len() - 1].join(", "); let end = &tokens[tokens.len() - 1]; @@ -52,7 +52,7 @@ pub fn parse_error(input: &[Token], error: &ParseError) -> TokenStream { UnrecognizedEOF { expected, .. } => { let msg = format!( "unexpected end of macro; missing {}", - pprint_tokens(&expected) + pprint_tokens(expected) ); quote! { compile_error! { #msg } @@ -63,7 +63,7 @@ pub fn parse_error(input: &[Token], error: &ParseError) -> TokenStream { expected, } => { let span = token.span(); - let error_msg = format!("expected {}", pprint_tokens(&expected)); + let error_msg = format!("expected {}", pprint_tokens(expected)); let error = quote_spanned! {span=> compile_error! { #error_msg } }; diff --git a/macros/src/html.rs b/macros/src/html.rs index 96b592b..85fd4f9 100644 --- a/macros/src/html.rs +++ b/macros/src/html.rs @@ -240,7 +240,7 @@ impl Element { } for (key, value) in data_attrs .iter() - .map(|(k, v)| (TokenTree::from(Literal::string(&k)), v.clone())) + .map(|(k, v)| (TokenTree::from(Literal::string(k)), v.clone())) { body.extend(quote!( element.data_attributes.push((#key, #value.into())); diff --git a/macros/src/span.rs b/macros/src/span.rs index d1e18cf..3ef37f7 100644 --- a/macros/src/span.rs +++ b/macros/src/span.rs @@ -1,5 +1,5 @@ -use proc_macro; -use proc_macro2; + + pub fn from_unstable(span: proc_macro::Span) -> proc_macro2::Span { let ident = proc_macro::Ident::new("_", span); diff --git a/typed-html/src/output/stdweb.rs b/typed-html/src/output/stdweb.rs index d96baf6..bfe4709 100644 --- a/typed-html/src/output/stdweb.rs +++ b/typed-html/src/output/stdweb.rs @@ -173,12 +173,12 @@ impl Stdweb { vnode: VNode<'_, Stdweb>, ) -> Result { match vnode { - VNode::Text(text) => Ok(document.create_text_node(&text).into()), - VNode::UnsafeText(text) => Ok(document.create_text_node(&text).into()), + VNode::Text(text) => Ok(document.create_text_node(text).into()), + VNode::UnsafeText(text) => Ok(document.create_text_node(text).into()), VNode::Element(element) => { let mut node = document.create_element(element.name)?; for (key, value) in element.attributes { - node.set_attribute(&key, &value)?; + node.set_attribute(key, &value)?; } Stdweb::install_handlers(&mut node, element.events); for child in element.children {