@@ -1736,8 +1736,34 @@ impl<A: Allocator + Clone> RawTableInner<A> {
1736
1736
1737
1737
/// Sets a control byte to the hash, and possibly also the replicated control byte at
1738
1738
/// the end of the array.
1739
+ ///
1740
+ /// This function does not make any changes to the `data` parts of the table,
1741
+ /// or any changes to the the `items` or `growth_left` field of the table.
1742
+ ///
1743
+ /// # Safety
1744
+ ///
1745
+ /// The safety rules are directly derived from the safety rules for [`RawTableInner::set_ctrl`]
1746
+ /// method. Thus, in order to uphold the safety contracts for the method, you must observe the
1747
+ /// following rules when calling this function:
1748
+ ///
1749
+ /// * The [`RawTableInner`] has already been allocated;
1750
+ ///
1751
+ /// * The `index` must not be greater than the `RawTableInner.bucket_mask`, i.e.
1752
+ /// `index <= RawTableInner.bucket_mask` or, in other words, `(index + 1)` must
1753
+ /// be no greater than the number returned by the function [`RawTableInner::buckets`].
1754
+ ///
1755
+ /// Calling this function on a table that has not been allocated results in [`undefined behavior`].
1756
+ ///
1757
+ /// See also [`Bucket::as_ptr`] method, for more information about of properly removing
1758
+ /// or saving `data element` from / into the [`RawTable`] / [`RawTableInner`].
1759
+ ///
1760
+ /// [`RawTableInner::set_ctrl`]: RawTableInner::set_ctrl
1761
+ /// [`RawTableInner::buckets`]: RawTableInner::buckets
1762
+ /// [`Bucket::as_ptr`]: Bucket::as_ptr
1763
+ /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
1739
1764
#[ inline]
1740
1765
unsafe fn set_ctrl_h2 ( & self , index : usize , hash : u64 ) {
1766
+ // SAFETY: The caller must uphold the safety rules for the [`RawTableInner::set_ctrl_h2`]
1741
1767
self . set_ctrl ( index, h2 ( hash) ) ;
1742
1768
}
1743
1769
0 commit comments