Skip to content

Commit

Permalink
refactor: rust 1.83 clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ccbrown committed Dec 20, 2024
1 parent 7721cb9 commit 32a46bc
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/iocraft/src/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions packages/iocraft/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> Sealed for Element<'_, T> where T: Component {}
impl<T> Sealed for &mut Element<'_, T> where T: Component {}
}

/// A trait implemented by all element types, providing methods for common operations on them.
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions packages/iocraft/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use core::{
/// and it can be invoked using function call syntax.
pub struct Handler<'a, T>(bool, Box<dyn FnMut(T) + Send + Sync + 'a>);

impl<'a, T> Handler<'a, T> {
impl<T> Handler<'_, T> {
/// Returns `true` if the handler was default-initialized.
pub fn is_default(&self) -> bool {
!self.0
Expand All @@ -21,7 +21,7 @@ impl<'a, T> Handler<'a, T> {
}
}

impl<'a, T> Default for Handler<'a, T> {
impl<T> Default for Handler<'_, T> {
fn default() -> Self {
Self(false, Box::new(|_| {}))
}
Expand Down
2 changes: 1 addition & 1 deletion packages/iocraft/src/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Box<dyn AnyHook>>, first_update: bool) -> Self {
Self {
hooks,
Expand Down
8 changes: 4 additions & 4 deletions packages/iocraft/src/hooks/use_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub struct StateRef<'a, T: 'static> {
inner: <SyncStorage as AnyStorage>::Ref<'a, StateValue<T>>,
}

impl<'a, T: 'static> ops::Deref for StateRef<'a, T> {
impl<T: 'static> ops::Deref for StateRef<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
Expand All @@ -121,22 +121,22 @@ pub struct StateMutRef<'a, T: 'static> {
did_deref_mut: bool,
}

impl<'a, T: 'static> ops::Deref for StateMutRef<'a, T> {
impl<T: 'static> ops::Deref for StateMutRef<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
&self.inner.value
}
}

impl<'a, T: 'static> ops::DerefMut for StateMutRef<'a, T> {
impl<T: 'static> 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<T: 'static> Drop for StateMutRef<'_, T> {
fn drop(&mut self) {
if self.did_deref_mut {
self.inner.did_change = true;
Expand Down
2 changes: 1 addition & 1 deletion packages/iocraft/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 32a46bc

Please sign in to comment.