about summary refs log tree commit diff
path: root/src/liballoc/collections
diff options
context:
space:
mode:
authorStein Somers <git@steinsomers.be>2020-07-22 22:37:54 +0200
committerStein Somers <git@steinsomers.be>2020-07-23 18:29:07 +0200
commitfacc46fd0a85408bc05aa19b80131e3cfb5fe3dd (patch)
tree59295e01c4cd59d204c821c0373724aa2863bf07 /src/liballoc/collections
parent7d31ffc1ac9e9ea356e896e63307168a64501b9d (diff)
downloadrust-facc46fd0a85408bc05aa19b80131e3cfb5fe3dd.tar.gz
rust-facc46fd0a85408bc05aa19b80131e3cfb5fe3dd.zip
BTreeMap::drain_filter: replace needless unsafety and test
Diffstat (limited to 'src/liballoc/collections')
-rw-r--r--src/liballoc/collections/btree/map.rs9
1 files changed, 1 insertions, 8 deletions
diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs
index bf5748739d4..09b24fde746 100644
--- a/src/liballoc/collections/btree/map.rs
+++ b/src/liballoc/collections/btree/map.rs
@@ -1681,19 +1681,12 @@ impl<'a, K: 'a, V: 'a> DrainFilterInner<'a, K, V> {
         edge.reborrow().next_kv().ok().map(|kv| kv.into_kv())
     }
 
-    unsafe fn next_kv(
-        &mut self,
-    ) -> Option<Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>, marker::KV>> {
-        let edge = self.cur_leaf_edge.as_ref()?;
-        unsafe { ptr::read(edge).next_kv().ok() }
-    }
-
     /// Implementation of a typical `DrainFilter::next` method, given the predicate.
     pub(super) fn next<F>(&mut self, pred: &mut F) -> Option<(K, V)>
     where
         F: FnMut(&K, &mut V) -> bool,
     {
-        while let Some(mut kv) = unsafe { self.next_kv() } {
+        while let Ok(mut kv) = self.cur_leaf_edge.take()?.next_kv() {
             let (k, v) = kv.kv_mut();
             if pred(k, v) {
                 *self.length -= 1;