diff options
| author | Stein Somers <git@steinsomers.be> | 2020-07-23 16:30:54 +0200 |
|---|---|---|
| committer | Stein Somers <git@steinsomers.be> | 2020-07-28 15:21:27 +0200 |
| commit | c4f4639e1a2eb07d17e7393a1c7f0594f0c11faf (patch) | |
| tree | e6514bc6e5bcd97ac69516fdd3dfd83979e41f43 | |
| parent | 1f5d69daccd1f04e42886d9aaf513f2691132d17 (diff) | |
| download | rust-c4f4639e1a2eb07d17e7393a1c7f0594f0c11faf.tar.gz rust-c4f4639e1a2eb07d17e7393a1c7f0594f0c11faf.zip | |
Remove into_slices and its unsafe block
| -rw-r--r-- | library/alloc/src/collections/btree/node.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index f7bd64608d6..9352c5806a4 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -466,12 +466,6 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Immut<'a>, K, V, Type> { fn into_val_slice(self) -> &'a [V] { unsafe { slice::from_raw_parts(MaybeUninit::first_ptr(&self.as_leaf().vals), self.len()) } } - - fn into_slices(self) -> (&'a [K], &'a [V]) { - // SAFETY: equivalent to reborrow() except not requiring Type: 'a - let k = unsafe { ptr::read(&self) }; - (k.into_key_slice(), self.into_val_slice()) - } } impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Mut<'a>, K, V, Type> { @@ -980,10 +974,9 @@ impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Internal>, marke impl<'a, K: 'a, V: 'a, NodeType> Handle<NodeRef<marker::Immut<'a>, K, V, NodeType>, marker::KV> { pub fn into_kv(self) -> (&'a K, &'a V) { - unsafe { - let (keys, vals) = self.node.into_slices(); - (keys.get_unchecked(self.idx), vals.get_unchecked(self.idx)) - } + let keys = self.node.into_key_slice(); + let vals = self.node.into_val_slice(); + unsafe { (keys.get_unchecked(self.idx), vals.get_unchecked(self.idx)) } } } |
