mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
f clarification, docs
This commit is contained in:
@@ -455,6 +455,11 @@ fn robin_hood<'a, K: 'a, V: 'a>(bucket: FullBucketMut<'a, K, V>,
|
||||
let bucket = bucket.put(hash, key, val);
|
||||
// Now that it's stolen, just read the value's pointer
|
||||
// right out of the table! Go back to the *starting point*.
|
||||
//
|
||||
// This use of `into_table` is misleading. It turns the
|
||||
// bucket, which is a FullBucket on top of a
|
||||
// FullBucketMut, into just one FullBucketMut. The "table"
|
||||
// refers to the inner FullBucketMut in this context.
|
||||
return bucket.into_table().into_mut_refs().1;
|
||||
},
|
||||
Full(bucket) => bucket
|
||||
|
||||
@@ -421,8 +421,9 @@ pub fn read(&self) -> (&K, &V) {
|
||||
}
|
||||
}
|
||||
|
||||
// We don't need a `Take` trait currently. This is why a mutable reference
|
||||
// to the table is required.
|
||||
// We take a mutable reference to the table instead of accepting anything that
|
||||
// implements `DerefMut` to prevent fn `take` from being called on `stash`ed
|
||||
// buckets.
|
||||
impl<'t, K, V> FullBucket<K, V, &'t mut RawTable<K, V>> {
|
||||
/// Removes this bucket's key and value from the hashtable.
|
||||
///
|
||||
@@ -446,6 +447,8 @@ pub fn take(mut self) -> (EmptyBucket<K, V, &'t mut RawTable<K, V>>, K, V) {
|
||||
}
|
||||
}
|
||||
|
||||
// This use of `Put` is misleading and restrictive, but safe and sufficient for our use cases
|
||||
// where `M` is a full bucket or table reference type with mutable access to the table.
|
||||
impl<K, V, M> FullBucket<K, V, M> where M: Put<K, V> {
|
||||
pub fn replace(&mut self, h: SafeHash, k: K, v: V) -> (SafeHash, K, V) {
|
||||
unsafe {
|
||||
|
||||
Reference in New Issue
Block a user