From 9bcc427b57ddb156b70fdba83b2d6a0cad88252a Mon Sep 17 00:00:00 2001 From: Hugo Rosenkranz-Costa Date: Wed, 10 Jan 2024 10:47:28 +0100 Subject: [PATCH] fix: false positive identity map warning --- src/data_struct/README.md | 4 +++- src/data_struct/dictionary.rs | 1 + src/data_struct/revision_vec.rs | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/data_struct/README.md b/src/data_struct/README.md index 07e3094d..2630c34d 100644 --- a/src/data_struct/README.md +++ b/src/data_struct/README.md @@ -13,7 +13,7 @@ Pros: - same serialized size -- accessing elements is the almost as fast as an `HashMap` with one additional memory access +- accessing elements is almost as fast as an `HashMap` with one additional memory access - updating the key of an element (e.g. renaming an attribute) can be performed in constant time without modifying the order @@ -68,6 +68,8 @@ Cons: - no direct access to a given coordinate's keys (would be a nice to have but not really needed in practice) +- multiple insertions with the same coordinate will result in multiple entries in the vector thus corrupting the structure + - following linked list pointers can be slower than iterating a regular vector - serialization requires following each linked list diff --git a/src/data_struct/dictionary.rs b/src/data_struct/dictionary.rs index 4ffadd55..d491054a 100644 --- a/src/data_struct/dictionary.rs +++ b/src/data_struct/dictionary.rs @@ -151,6 +151,7 @@ where } /// Returns an iterator over keys and values in insertion order. + #[allow(clippy::map_identity)] // unpack &(x, y) to (&x, &y) pub fn iter(&self) -> impl Iterator { self.entries.iter().map(|(k, v)| (k, v)) } diff --git a/src/data_struct/revision_vec.rs b/src/data_struct/revision_vec.rs index 194e65db..d875823f 100644 --- a/src/data_struct/revision_vec.rs +++ b/src/data_struct/revision_vec.rs @@ -81,11 +81,13 @@ impl RevisionVec { } /// Returns an iterator over each key-chains pair + #[allow(clippy::map_identity)] // unpack &(x, y) to (&x, &y) pub fn iter(&self) -> impl Iterator)> { self.chains.iter().map(|(key, chain)| (key, chain)) } /// Returns an iterator over each key-chains pair that allow modifying chain + #[allow(clippy::map_identity)] // unpack &mut (x, y) to (&x, &mut y) pub fn iter_mut(&mut self) -> impl Iterator)> where K: Clone,