Skip to content

Commit 1052f4d

Browse files
committed
Also relax bounds on PartialEq for LinearMap.
1 parent 6c6ba16 commit 1052f4d

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10-
- Relax bounds on `IndexMap` from `V: Eq` to `V: PartialEq`.
11-
1210
### Added
1311

1412
- Added `format` macro.
@@ -60,6 +58,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6058
- Changed `stable_deref_trait` to a platform-dependent dependency.
6159
- Changed `SortedLinkedList::pop` return type from `Result<T, ()>` to `Option<T>` to match `std::vec::pop`.
6260
- `Vec::capacity` is no longer a `const` function.
61+
- Relaxed bounds on `PartialEq` for `IndexMap` from `V: Eq` to `V1: PartialEq<V2>`.
62+
- Relaxed bounds on `PartialEq` for `LinearMap` from `V: PartialEq` to `V1: PartialEq<V2>`.
6363

6464
### Fixed
6565

src/linear_map.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,13 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> {
614614
}
615615
}
616616

617-
impl<K, V, S1: LinearMapStorage<K, V> + ?Sized, S2: LinearMapStorage<K, V> + ?Sized>
618-
PartialEq<LinearMapInner<K, V, S2>> for LinearMapInner<K, V, S1>
617+
impl<K, V1, V2, S1: LinearMapStorage<K, V1> + ?Sized, S2: LinearMapStorage<K, V2> + ?Sized>
618+
PartialEq<LinearMapInner<K, V2, S2>> for LinearMapInner<K, V1, S1>
619619
where
620620
K: Eq,
621-
V: PartialEq,
621+
V1: PartialEq<V2>,
622622
{
623-
fn eq(&self, other: &LinearMapInner<K, V, S2>) -> bool {
623+
fn eq(&self, other: &LinearMapInner<K, V2, S2>) -> bool {
624624
self.len() == other.len()
625625
&& self
626626
.iter()
@@ -745,4 +745,11 @@ mod test {
745745
) -> &'c LinearMapView<&'b (), u32> {
746746
x
747747
}
748+
749+
#[test]
750+
fn partial_eq_floats() {
751+
// Make sure `PartialEq` is implemented even if `V` doesn't implement `Eq`.
752+
let map: LinearMap<usize, f32, 4> = Default::default();
753+
assert_eq!(map, map);
754+
}
748755
}

0 commit comments

Comments
 (0)