Auto merge of #81956 - ssomers:btree_post_75200, r=Mark-Simulacrum
BTree: remove outdated traces of coercions The introduction of `marker::ValMut` (#75200) meant iterators no longer see mutable keys but their code still pretends it does. And settle on the majority style `Some(unsafe {…})` over `unsafe { Some(…) }`. r? `@Mark-Simulacrum`
This commit is contained in:
commit
b86674e7cc
1 changed files with 7 additions and 19 deletions
|
@ -1279,7 +1279,7 @@ impl<'a, K: 'a, V: 'a> Iterator for Iter<'a, K, V> {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
self.length -= 1;
|
self.length -= 1;
|
||||||
unsafe { Some(self.range.next_unchecked()) }
|
Some(unsafe { self.range.next_unchecked() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1310,7 +1310,7 @@ impl<'a, K: 'a, V: 'a> DoubleEndedIterator for Iter<'a, K, V> {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
self.length -= 1;
|
self.length -= 1;
|
||||||
unsafe { Some(self.range.next_back_unchecked()) }
|
Some(unsafe { self.range.next_back_unchecked() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1348,8 +1348,7 @@ impl<'a, K: 'a, V: 'a> Iterator for IterMut<'a, K, V> {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
self.length -= 1;
|
self.length -= 1;
|
||||||
let (k, v) = unsafe { self.range.next_unchecked() };
|
Some(unsafe { self.range.next_unchecked() })
|
||||||
Some((k, v)) // coerce k from `&mut K` to `&K`
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1377,8 +1376,7 @@ impl<'a, K: 'a, V: 'a> DoubleEndedIterator for IterMut<'a, K, V> {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
self.length -= 1;
|
self.length -= 1;
|
||||||
let (k, v) = unsafe { self.range.next_back_unchecked() };
|
Some(unsafe { self.range.next_back_unchecked() })
|
||||||
Some((k, v)) // coerce k from `&mut K` to `&K`
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1700,7 +1698,7 @@ impl<'a, K, V> Iterator for Range<'a, K, V> {
|
||||||
type Item = (&'a K, &'a V);
|
type Item = (&'a K, &'a V);
|
||||||
|
|
||||||
fn next(&mut self) -> Option<(&'a K, &'a V)> {
|
fn next(&mut self) -> Option<(&'a K, &'a V)> {
|
||||||
if self.is_empty() { None } else { unsafe { Some(self.next_unchecked()) } }
|
if self.is_empty() { None } else { Some(unsafe { self.next_unchecked() }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn last(mut self) -> Option<(&'a K, &'a V)> {
|
fn last(mut self) -> Option<(&'a K, &'a V)> {
|
||||||
|
@ -1864,12 +1862,7 @@ impl<'a, K, V> Iterator for RangeMut<'a, K, V> {
|
||||||
type Item = (&'a K, &'a mut V);
|
type Item = (&'a K, &'a mut V);
|
||||||
|
|
||||||
fn next(&mut self) -> Option<(&'a K, &'a mut V)> {
|
fn next(&mut self) -> Option<(&'a K, &'a mut V)> {
|
||||||
if self.is_empty() {
|
if self.is_empty() { None } else { Some(unsafe { self.next_unchecked() }) }
|
||||||
None
|
|
||||||
} else {
|
|
||||||
let (k, v) = unsafe { self.next_unchecked() };
|
|
||||||
Some((k, v)) // coerce k from `&mut K` to `&K`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn last(mut self) -> Option<(&'a K, &'a mut V)> {
|
fn last(mut self) -> Option<(&'a K, &'a mut V)> {
|
||||||
|
@ -1907,12 +1900,7 @@ impl<'a, K, V> RangeMut<'a, K, V> {
|
||||||
#[stable(feature = "btree_range", since = "1.17.0")]
|
#[stable(feature = "btree_range", since = "1.17.0")]
|
||||||
impl<'a, K, V> DoubleEndedIterator for RangeMut<'a, K, V> {
|
impl<'a, K, V> DoubleEndedIterator for RangeMut<'a, K, V> {
|
||||||
fn next_back(&mut self) -> Option<(&'a K, &'a mut V)> {
|
fn next_back(&mut self) -> Option<(&'a K, &'a mut V)> {
|
||||||
if self.is_empty() {
|
if self.is_empty() { None } else { Some(unsafe { self.next_back_unchecked() }) }
|
||||||
None
|
|
||||||
} else {
|
|
||||||
let (k, v) = unsafe { self.next_back_unchecked() };
|
|
||||||
Some((k, v)) // coerce k from `&mut K` to `&K`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue