From 1052f4d7839c6b7214d75f82f7417ca543babac6 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 6 Apr 2025 01:11:24 +0200 Subject: [PATCH] Also relax bounds on `PartialEq` for `LinearMap`. --- CHANGELOG.md | 4 ++-- src/linear_map.rs | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a4e64b8..953abcff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -- Relax bounds on `IndexMap` from `V: Eq` to `V: PartialEq`. - ### Added - Added `format` macro. @@ -60,6 +58,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Changed `stable_deref_trait` to a platform-dependent dependency. - Changed `SortedLinkedList::pop` return type from `Result` to `Option` to match `std::vec::pop`. - `Vec::capacity` is no longer a `const` function. +- Relaxed bounds on `PartialEq` for `IndexMap` from `V: Eq` to `V1: PartialEq`. +- Relaxed bounds on `PartialEq` for `LinearMap` from `V: PartialEq` to `V1: PartialEq`. ### Fixed diff --git a/src/linear_map.rs b/src/linear_map.rs index d4e137cc..c96dece1 100644 --- a/src/linear_map.rs +++ b/src/linear_map.rs @@ -614,13 +614,13 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> { } } -impl + ?Sized, S2: LinearMapStorage + ?Sized> - PartialEq> for LinearMapInner +impl + ?Sized, S2: LinearMapStorage + ?Sized> + PartialEq> for LinearMapInner where K: Eq, - V: PartialEq, + V1: PartialEq, { - fn eq(&self, other: &LinearMapInner) -> bool { + fn eq(&self, other: &LinearMapInner) -> bool { self.len() == other.len() && self .iter() @@ -745,4 +745,11 @@ mod test { ) -> &'c LinearMapView<&'b (), u32> { x } + + #[test] + fn partial_eq_floats() { + // Make sure `PartialEq` is implemented even if `V` doesn't implement `Eq`. + let map: LinearMap = Default::default(); + assert_eq!(map, map); + } }