Skip to content

Commit 64adca7

Browse files
committed
f clarification, docs
1 parent c9b3cd4 commit 64adca7

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/libstd/collections/hash/map.rs

+5
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,11 @@ fn robin_hood<'a, K: 'a, V: 'a>(bucket: FullBucketMut<'a, K, V>,
455455
let bucket = bucket.put(hash, key, val);
456456
// Now that it's stolen, just read the value's pointer
457457
// right out of the table! Go back to the *starting point*.
458+
//
459+
// This use of `into_table` is misleading. It turns the
460+
// bucket, which is a FullBucket on top of a
461+
// FullBucketMut, into just one FullBucketMut. The "table"
462+
// refers to the inner FullBucketMut in this context.
458463
return bucket.into_table().into_mut_refs().1;
459464
},
460465
Full(bucket) => bucket

src/libstd/collections/hash/table.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,9 @@ impl<K, V, M: Deref<Target=RawTable<K, V>>> FullBucket<K, V, M> {
421421
}
422422
}
423423

424-
// We don't need a `Take` trait currently. This is why a mutable reference
425-
// to the table is required.
424+
// We take a mutable reference to the table instead of accepting anything that
425+
// implements `DerefMut` to prevent fn `take` from being called on `stash`ed
426+
// buckets.
426427
impl<'t, K, V> FullBucket<K, V, &'t mut RawTable<K, V>> {
427428
/// Removes this bucket's key and value from the hashtable.
428429
///
@@ -446,6 +447,8 @@ impl<'t, K, V> FullBucket<K, V, &'t mut RawTable<K, V>> {
446447
}
447448
}
448449

450+
// This use of `Put` is misleading and restrictive, but safe and sufficient for our use cases
451+
// where `M` is a full bucket or table reference type with mutable access to the table.
449452
impl<K, V, M> FullBucket<K, V, M> where M: Put<K, V> {
450453
pub fn replace(&mut self, h: SafeHash, k: K, v: V) -> (SafeHash, K, V) {
451454
unsafe {

0 commit comments

Comments
 (0)