Also relax bounds on PartialEq for LinearMap.

This commit is contained in:
Markus Reiter 2025-04-06 01:11:24 +02:00
parent 6c6ba16921
commit 1052f4d783
No known key found for this signature in database
2 changed files with 13 additions and 6 deletions

View File

@ -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<T, ()>` to `Option<T>` 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<V2>`.
- Relaxed bounds on `PartialEq` for `LinearMap` from `V: PartialEq` to `V1: PartialEq<V2>`.
### Fixed

View File

@ -614,13 +614,13 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> {
}
}
impl<K, V, S1: LinearMapStorage<K, V> + ?Sized, S2: LinearMapStorage<K, V> + ?Sized>
PartialEq<LinearMapInner<K, V, S2>> for LinearMapInner<K, V, S1>
impl<K, V1, V2, S1: LinearMapStorage<K, V1> + ?Sized, S2: LinearMapStorage<K, V2> + ?Sized>
PartialEq<LinearMapInner<K, V2, S2>> for LinearMapInner<K, V1, S1>
where
K: Eq,
V: PartialEq,
V1: PartialEq<V2>,
{
fn eq(&self, other: &LinearMapInner<K, V, S2>) -> bool {
fn eq(&self, other: &LinearMapInner<K, V2, S2>) -> 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<usize, f32, 4> = Default::default();
assert_eq!(map, map);
}
}