Commit fcca2d6
committed
Auto merge of rust-lang#321 - JustForFun88:JustForFun88-patch-1, r=Amanieu
Correct the implementation of Debug for ValuesMut and IntoValues structures
Previously the implementation of Debug trait for ValuesMut was
```
impl<K, V> fmt::Debug for ValuesMut<'_, K, V>
where
K: fmt::Debug,
V: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_list().entries(self.inner.iter()).finish()
}
}
```
It is strange, because `self.inner.iter()` return an iterator with element of type `(&’a K, &’a V)`.
The same is true when we look at the old implementation of Debug trait for the `IntoValues` structure. Here we have mistake
```
impl<K: Debug, V: Debug, A: Allocator + Clone> fmt::Debug for IntoValues<K, V, A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_list()
.entries(self.inner.iter().map(|(k, _)| k))
.finish()
}
}
```
because with the function `self.inner.iter().map(|(k, _)| k)` we return iterator with element of type 'a K.1 file changed
+6
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1942 | 1942 | | |
1943 | 1943 | | |
1944 | 1944 | | |
1945 | | - | |
| 1945 | + | |
1946 | 1946 | | |
1947 | 1947 | | |
1948 | | - | |
| 1948 | + | |
1949 | 1949 | | |
1950 | 1950 | | |
1951 | 1951 | | |
| |||
3149 | 3149 | | |
3150 | 3150 | | |
3151 | 3151 | | |
3152 | | - | |
3153 | | - | |
3154 | | - | |
3155 | | - | |
3156 | | - | |
| 3152 | + | |
3157 | 3153 | | |
3158 | | - | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
3159 | 3157 | | |
3160 | 3158 | | |
3161 | 3159 | | |
| |||
0 commit comments