@@ -1301,8 +1301,34 @@ impl<A: Allocator + Clone> RawTableInner<A> {
1301
1301
1302
1302
/// Sets a control byte to the hash, and possibly also the replicated control byte at
1303
1303
/// the end of the array.
1304
+ ///
1305
+ /// This function does not make any changes to the `data` parts of the table,
1306
+ /// or any changes to the the `items` or `growth_left` field of the table.
1307
+ ///
1308
+ /// # Safety
1309
+ ///
1310
+ /// The safety rules are directly derived from the safety rules for [`RawTableInner::set_ctrl`]
1311
+ /// method. Thus, in order to uphold the safety contracts for the method, you must observe the
1312
+ /// following rules when calling this function:
1313
+ ///
1314
+ /// * The [`RawTableInner`] has already been allocated;
1315
+ ///
1316
+ /// * The `index` must not be greater than the `RawTableInner.bucket_mask`, i.e.
1317
+ /// `index <= RawTableInner.bucket_mask` or, in other words, `(index + 1)` must
1318
+ /// be no greater than the number returned by the function [`RawTableInner::buckets`].
1319
+ ///
1320
+ /// Calling this function on a table that has not been allocated results in [`undefined behavior`].
1321
+ ///
1322
+ /// See also [`Bucket::as_ptr`] method, for more information about of properly removing
1323
+ /// or saving `data element` from / into the [`RawTable`] / [`RawTableInner`].
1324
+ ///
1325
+ /// [`RawTableInner::set_ctrl`]: RawTableInner::set_ctrl
1326
+ /// [`RawTableInner::buckets`]: RawTableInner::buckets
1327
+ /// [`Bucket::as_ptr`]: Bucket::as_ptr
1328
+ /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
1304
1329
#[ inline]
1305
1330
unsafe fn set_ctrl_h2 ( & self , index : usize , hash : u64 ) {
1331
+ // SAFETY: The caller must uphold the safety rules for the [`RawTableInner::set_ctrl_h2`]
1306
1332
self . set_ctrl ( index, h2 ( hash) ) ;
1307
1333
}
1308
1334
0 commit comments