From 32a46bc3e39d93bf4919b159e18b1e0295e909ab Mon Sep 17 00:00:00 2001 From: Chris Brown <1731074+ccbrown@users.noreply.github.com> Date: Fri, 20 Dec 2024 17:27:59 -0500 Subject: [PATCH] refactor: rust 1.83 clippy fixes --- packages/iocraft/src/canvas.rs | 2 +- packages/iocraft/src/element.rs | 9 +++++---- packages/iocraft/src/handler.rs | 4 ++-- packages/iocraft/src/hook.rs | 2 +- packages/iocraft/src/hooks/use_state.rs | 8 ++++---- packages/iocraft/src/render.rs | 2 +- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/iocraft/src/canvas.rs b/packages/iocraft/src/canvas.rs index f16b476..c4c8b47 100644 --- a/packages/iocraft/src/canvas.rs +++ b/packages/iocraft/src/canvas.rs @@ -322,7 +322,7 @@ pub struct CanvasSubviewMut<'a> { canvas: &'a mut Canvas, } -impl<'a> CanvasSubviewMut<'a> { +impl CanvasSubviewMut<'_> { /// Fills the region with the given color. pub fn set_background_color(&mut self, x: isize, y: isize, w: usize, h: usize, color: Color) { let mut left = self.x as isize + x; diff --git a/packages/iocraft/src/element.rs b/packages/iocraft/src/element.rs index aecc946..339a53c 100644 --- a/packages/iocraft/src/element.rs +++ b/packages/iocraft/src/element.rs @@ -145,10 +145,10 @@ mod private { use super::*; pub trait Sealed {} - impl<'a> Sealed for AnyElement<'a> {} - impl<'a> Sealed for &mut AnyElement<'a> {} - impl<'a, T> Sealed for Element<'a, T> where T: Component {} - impl<'a, T> Sealed for &mut Element<'a, T> where T: Component {} + impl Sealed for AnyElement<'_> {} + impl Sealed for &mut AnyElement<'_> {} + impl Sealed for Element<'_, T> where T: Component {} + impl Sealed for &mut Element<'_, T> where T: Component {} } /// A trait implemented by all element types, providing methods for common operations on them. @@ -414,6 +414,7 @@ where mod tests { use crate::prelude::*; + #[allow(clippy::unnecessary_mut_passed)] #[test] fn test_element() { let mut box_element = element!(Box); diff --git a/packages/iocraft/src/handler.rs b/packages/iocraft/src/handler.rs index ef02d26..98db22f 100644 --- a/packages/iocraft/src/handler.rs +++ b/packages/iocraft/src/handler.rs @@ -9,7 +9,7 @@ use core::{ /// and it can be invoked using function call syntax. pub struct Handler<'a, T>(bool, Box); -impl<'a, T> Handler<'a, T> { +impl Handler<'_, T> { /// Returns `true` if the handler was default-initialized. pub fn is_default(&self) -> bool { !self.0 @@ -21,7 +21,7 @@ impl<'a, T> Handler<'a, T> { } } -impl<'a, T> Default for Handler<'a, T> { +impl Default for Handler<'_, T> { fn default() -> Self { Self(false, Box::new(|_| {})) } diff --git a/packages/iocraft/src/hook.rs b/packages/iocraft/src/hook.rs index 0cb97fa..7134af1 100644 --- a/packages/iocraft/src/hook.rs +++ b/packages/iocraft/src/hook.rs @@ -92,7 +92,7 @@ pub struct Hooks<'a, 'b: 'a> { pub(crate) context_stack: Option<&'a ContextStack<'b>>, } -impl<'a, 'b> Hooks<'a, 'b> { +impl<'a> Hooks<'a, '_> { pub(crate) fn new(hooks: &'a mut Vec>, first_update: bool) -> Self { Self { hooks, diff --git a/packages/iocraft/src/hooks/use_state.rs b/packages/iocraft/src/hooks/use_state.rs index 2209c68..81b6e03 100644 --- a/packages/iocraft/src/hooks/use_state.rs +++ b/packages/iocraft/src/hooks/use_state.rs @@ -107,7 +107,7 @@ pub struct StateRef<'a, T: 'static> { inner: ::Ref<'a, StateValue>, } -impl<'a, T: 'static> ops::Deref for StateRef<'a, T> { +impl ops::Deref for StateRef<'_, T> { type Target = T; fn deref(&self) -> &Self::Target { @@ -121,7 +121,7 @@ pub struct StateMutRef<'a, T: 'static> { did_deref_mut: bool, } -impl<'a, T: 'static> ops::Deref for StateMutRef<'a, T> { +impl ops::Deref for StateMutRef<'_, T> { type Target = T; fn deref(&self) -> &Self::Target { @@ -129,14 +129,14 @@ impl<'a, T: 'static> ops::Deref for StateMutRef<'a, T> { } } -impl<'a, T: 'static> ops::DerefMut for StateMutRef<'a, T> { +impl ops::DerefMut for StateMutRef<'_, T> { fn deref_mut(&mut self) -> &mut Self::Target { self.did_deref_mut = true; &mut self.inner.value } } -impl<'a, T: 'static> Drop for StateMutRef<'a, T> { +impl Drop for StateMutRef<'_, T> { fn drop(&mut self) { if self.did_deref_mut { self.inner.did_change = true; diff --git a/packages/iocraft/src/render.rs b/packages/iocraft/src/render.rs index 7c98e7d..06c9744 100644 --- a/packages/iocraft/src/render.rs +++ b/packages/iocraft/src/render.rs @@ -219,7 +219,7 @@ pub struct ComponentDrawer<'a> { context: DrawContext<'a>, } -impl<'a> ComponentDrawer<'a> { +impl ComponentDrawer<'_> { /// Gets the calculated layout of the current node. pub fn layout(&self) -> Layout { *self