gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 227Rust 7TOML 3CSS 1307 Definiciones

Fix clippy lints (2024-03) (#630)

* Add Default implementations for Cache and Layout (clippy)

* Make test module attributes uniform (clippy)

* Remove unnecessary clippy ignores

dc9862a93be77bb2af8f5b27f6efe6304f3126e1 · por Nico Burns · (hace 2 años) · padre bb3ec967e · ver el árbol en este commit

Delta semántico · 2

src/tree/cache.rs

src/tree/layout.rs

5 archivos · +12 −5

diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs
index aebbd75b4..4af14ae1e 100644
--- a/src/compute/flexbox.rs
+++ b/src/compute/flexbox.rs
@@ -2154,7 +2154,6 @@ fn sum_axis_gaps(gap: f32, num_items: usize) -> f32 {
 
 #[cfg(test)]
 mod tests {
-    #![allow(clippy::redundant_clone)]
 
     use crate::{
         geometry::Size,
diff --git a/src/compute/grid/placement.rs b/src/compute/grid/placement.rs
index f9fe6c5ad..bd760accb 100644
--- a/src/compute/grid/placement.rs
+++ b/src/compute/grid/placement.rs
@@ -340,11 +340,8 @@ fn record_grid_placement(
     println!("\n");
 }
 
-#[allow(clippy::bool_assert_comparison)]
 #[cfg(test)]
 mod tests {
-    // It's more readable if the test code is uniform, so we tolerate unnecessary clones in tests
-    #![allow(clippy::redundant_clone)]
 
     mod test_placement_algorithm {
         use crate::compute::grid::implicit_grid::compute_grid_size_estimate;
diff --git a/src/tree/cache.rs b/src/tree/cache.rs
index 679f94874..c131158ab 100644
--- a/src/tree/cache.rs
+++ b/src/tree/cache.rs
@@ -25,6 +25,12 @@ pub struct Cache {
     measure_entries: [Option<CacheEntry<Size<f32>>>; CACHE_SIZE],
 }
 
+impl Default for Cache {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
 impl Cache {
     /// Create a new empty cache
     pub const fn new() -> Self {
diff --git a/src/tree/layout.rs b/src/tree/layout.rs
index f067901d1..b490a1d29 100644
--- a/src/tree/layout.rs
+++ b/src/tree/layout.rs
@@ -235,6 +235,12 @@ pub struct Layout {
     pub padding: Rect<f32>,
 }
 
+impl Default for Layout {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
 impl Layout {
     /// Creates a new zero-[`Layout`].
     ///
diff --git a/src/tree/taffy_tree.rs b/src/tree/taffy_tree.rs
index 7a8f4bd9d..b465bed5a 100644
--- a/src/tree/taffy_tree.rs
+++ b/src/tree/taffy_tree.rs
@@ -703,7 +703,6 @@ impl<NodeContext> TaffyTree<NodeContext> {
 
 #[cfg(test)]
 mod tests {
-    #![allow(clippy::bool_assert_comparison)]
 
     use super::*;
     use crate::style::{Dimension, Display, FlexDirection};