From 49da073fed27d2f26269a9bf847e4d045d0c4783 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Fri, 10 May 2024 17:19:40 -0400 Subject: [PATCH] chore: fix warnings about variable case --- tachys/src/html/attribute/mod.rs | 68 ++++++++++++++++---------------- tachys/src/view/tuples.rs | 61 +++++++++++++--------------- 2 files changed, 60 insertions(+), 69 deletions(-) diff --git a/tachys/src/html/attribute/mod.rs b/tachys/src/html/attribute/mod.rs index ce40a0916..db26f7061 100644 --- a/tachys/src/html/attribute/mod.rs +++ b/tachys/src/html/attribute/mod.rs @@ -221,35 +221,32 @@ macro_rules! impl_attr_for_tuples { } fn to_html(self, buf: &mut String, class: &mut String, style: &mut String, inner_html: &mut String,) { - paste::paste! { - let ([<$first:lower>], $([<$ty:lower>],)* ) = self; - [<$first:lower>].to_html(buf, class, style, inner_html); - $([<$ty:lower>].to_html(buf, class, style, inner_html));* - } + #[allow(non_snake_case)] + let ($first, $($ty,)* ) = self; + $first.to_html(buf, class, style, inner_html); + $($ty.to_html(buf, class, style, inner_html));* } fn hydrate(self, el: &Rndr::Element) -> Self::State { - paste::paste! { - let ([<$first:lower>], $([<$ty:lower>],)* ) = self; + #[allow(non_snake_case)] + let ($first, $($ty,)* ) = self; ( - [<$first:lower>].hydrate::(el), - $([<$ty:lower>].hydrate::(el)),* + $first.hydrate::(el), + $($ty.hydrate::(el)),* ) - } } fn build(self, el: &Rndr::Element) -> Self::State { - paste::paste! { - let ([<$first:lower>], $([<$ty:lower>],)*) = self; + #[allow(non_snake_case)] + let ($first, $($ty,)*) = self; ( - [<$first:lower>].build(el), - $([<$ty:lower>].build(el)),* + $first.build(el), + $($ty.build(el)),* ) - } } fn rebuild(self, state: &mut Self::State) { - paste::paste! { + paste::paste! { let ([<$first:lower>], $([<$ty:lower>],)*) = self; let ([], $([],)*) = state; [<$first:lower>].rebuild([]); @@ -258,6 +255,7 @@ macro_rules! impl_attr_for_tuples { } fn into_cloneable(self) -> Self::Cloneable { + #[allow(non_snake_case)] let ($first, $($ty,)*) = self; ( $first.into_cloneable(), @@ -266,6 +264,7 @@ macro_rules! impl_attr_for_tuples { } fn into_cloneable_owned(self) -> Self::CloneableOwned { + #[allow(non_snake_case)] let ($first, $($ty,)*) = self; ( $first.into_cloneable_owned(), @@ -315,31 +314,28 @@ macro_rules! impl_attr_for_tuples_truncate_additional { } fn to_html(self, buf: &mut String, class: &mut String, style: &mut String, inner_html: &mut String,) { - paste::paste! { - let ([<$first:lower>], $([<$ty:lower>],)* ) = self; - [<$first:lower>].to_html(buf, class, style, inner_html); - $([<$ty:lower>].to_html(buf, class, style, inner_html));* - } + #[allow(non_snake_case)] + let ($first, $($ty,)* ) = self; + $first.to_html(buf, class, style, inner_html); + $($ty.to_html(buf, class, style, inner_html));* } fn hydrate(self, el: &Rndr::Element) -> Self::State { - paste::paste! { - let ([<$first:lower>], $([<$ty:lower>],)* ) = self; - ( - [<$first:lower>].hydrate::(el), - $([<$ty:lower>].hydrate::(el)),* - ) - } + #[allow(non_snake_case)] + let ($first, $($ty,)* ) = self; + ( + $first.hydrate::(el), + $($ty.hydrate::(el)),* + ) } fn build(self, el: &Rndr::Element) -> Self::State { - paste::paste! { - let ([<$first:lower>], $([<$ty:lower>],)*) = self; - ( - [<$first:lower>].build(el), - $([<$ty:lower>].build(el)),* - ) - } + #[allow(non_snake_case)] + let ($first, $($ty,)*) = self; + ( + $first.build(el), + $($ty.build(el)),* + ) } fn rebuild(self, state: &mut Self::State) { @@ -352,6 +348,7 @@ macro_rules! impl_attr_for_tuples_truncate_additional { } fn into_cloneable(self) -> Self::Cloneable { + #[allow(non_snake_case)] let ($first, $($ty,)*) = self; ( $first.into_cloneable(), @@ -360,6 +357,7 @@ macro_rules! impl_attr_for_tuples_truncate_additional { } fn into_cloneable_owned(self) -> Self::CloneableOwned { + #[allow(non_snake_case)] let ($first, $($ty,)*) = self; ( $first.into_cloneable_owned(), diff --git a/tachys/src/view/tuples.rs b/tachys/src/view/tuples.rs index 23fa92913..2c03786f0 100644 --- a/tachys/src/view/tuples.rs +++ b/tachys/src/view/tuples.rs @@ -217,11 +217,10 @@ macro_rules! impl_view_for_tuples { } fn to_html_with_buf(self, buf: &mut String, position: &mut Position) { - paste::paste! { - let ([<$first:lower>], $([<$ty:lower>],)* ) = self; - [<$first:lower>].to_html_with_buf(buf, position); - $([<$ty:lower>].to_html_with_buf(buf, position));* - } + #[allow(non_snake_case)] + let ($first, $($ty,)* ) = self; + $first.to_html_with_buf(buf, position); + $($ty.to_html_with_buf(buf, position));* } fn to_html_async_with_buf( @@ -231,21 +230,19 @@ macro_rules! impl_view_for_tuples { ) where Self: Sized, { - paste::paste! { - let ([<$first:lower>], $([<$ty:lower>],)* ) = self; - [<$first:lower>].to_html_async_with_buf::(buf, position); - $([<$ty:lower>].to_html_async_with_buf::(buf, position));* - } + #[allow(non_snake_case)] + let ($first, $($ty,)* ) = self; + $first.to_html_async_with_buf::(buf, position); + $($ty.to_html_async_with_buf::(buf, position));* } fn hydrate(self, cursor: &Cursor, position: &PositionState) -> Self::State { - paste::paste! { - let ([<$first:lower>], $([<$ty:lower>],)* ) = self; + #[allow(non_snake_case)] + let ($first, $($ty,)* ) = self; ( - [<$first:lower>].hydrate::(cursor, position), - $([<$ty:lower>].hydrate::(cursor, position)),* + $first.hydrate::(cursor, position), + $($ty.hydrate::(cursor, position)),* ) - } } async fn resolve(self) -> Self::AsyncOutput { @@ -274,10 +271,8 @@ macro_rules! impl_view_for_tuples { ], ";")); fn to_template(buf: &mut String, class: &mut String, style: &mut String, inner_html: &mut String, position: &mut Position) { - paste::paste! { - $first ::to_template(buf, class, style, inner_html, position); - $($ty::to_template(buf, class, style, inner_html, position));*; - } + $first ::to_template(buf, class, style, inner_html, position); + $($ty::to_template(buf, class, style, inner_html, position));*; } } @@ -287,11 +282,10 @@ macro_rules! impl_view_for_tuples { Rndr: Renderer { fn unmount(&mut self) { - paste::paste! { - let ([<$first:lower>], $([<$ty:lower>],)*) = self; - [<$first:lower>].unmount(); - $([<$ty:lower>].unmount());* - } + #[allow(non_snake_case)] // better macro performance + let ($first, $($ty,)*) = self; + $first.unmount(); + $($ty.unmount());* } fn mount( @@ -299,11 +293,10 @@ macro_rules! impl_view_for_tuples { parent: &Rndr::Element, marker: Option<&Rndr::Node>, ) { - paste::paste! { - let ([<$first:lower>], $([<$ty:lower>],)*) = self; - [<$first:lower>].mount(parent, marker); - $([<$ty:lower>].mount(parent, marker));* - } + #[allow(non_snake_case)] // better macro performance + let ($first, $($ty,)*) = self; + $first.mount(parent, marker); + $($ty.mount(parent, marker));* } fn insert_before_this( @@ -311,11 +304,10 @@ macro_rules! impl_view_for_tuples { parent: &Rndr::Element, child: &mut dyn Mountable, ) -> bool { - paste::paste! { - let ([<$first:lower>], $([<$ty:lower>],)*) = self; - [<$first:lower>].insert_before_this(parent, child) - $(|| [<$ty:lower>].insert_before_this(parent, child))* - } + #[allow(non_snake_case)] // better macro performance + let ($first, $($ty,)*) = self; + $first.insert_before_this(parent, child) + $(|| $ty.insert_before_this(parent, child))* } } @@ -335,6 +327,7 @@ macro_rules! impl_view_for_tuples { Self::Output: RenderHtml, { let shared = attr.into_cloneable(); + #[allow(non_snake_case)] // better macro performance let ($first, $($ty,)*) = self; ($first.add_any_attr(shared.clone()), $($ty.add_any_attr(shared.clone()),)*) }