1515// specific language governing permissions and limitations
1616// under the License.
1717
18- //! Utilities that help with tracking of memory allocations.
18+ //! [`VecAllocExt`] and [`RawTableAllocExt`] to help tracking of memory allocations
1919
2020use hashbrown:: raw:: { Bucket , RawTable } ;
2121
@@ -24,12 +24,18 @@ pub trait VecAllocExt {
2424 /// Item type.
2525 type T ;
2626
27- /// [Push](Vec::push) new element to vector and store additional allocated bytes in `accounting` (additive).
27+ /// [Push](Vec::push) new element to vector and increase
28+ /// `accounting` by any newly allocated bytes.
29+ ///
30+ /// Note that allocation counts capacity, not size
2831 fn push_accounted ( & mut self , x : Self :: T , accounting : & mut usize ) ;
2932
30- /// Return the amount of memory allocated by this Vec (not
31- /// recursively counting any heap allocations contained within the
32- /// structure). Does not include the size of `self`
33+ /// Return the amount of memory allocated by this Vec to store elements
34+ /// (`size_of<T> * capacity`).
35+ ///
36+ /// Note this calculation is not recursive, and does not include any heap
37+ /// allocations contained within the Vec's elements. Does not include the
38+ /// size of `self`
3339 fn allocated_size ( & self ) -> usize ;
3440}
3541
@@ -54,12 +60,15 @@ impl<T> VecAllocExt for Vec<T> {
5460 }
5561}
5662
57- /// Extension trait for [`RawTable`] to account for allocations.
63+ /// Extension trait for hash browns [`RawTable`] to account for allocations.
5864pub trait RawTableAllocExt {
5965 /// Item type.
6066 type T ;
6167
62- /// [Insert](RawTable::insert) new element into table and store additional allocated bytes in `accounting` (additive).
68+ /// [Insert](RawTable::insert) new element into table and increase
69+ /// `accounting` by any newly allocated bytes.
70+ ///
71+ /// Returns the bucket where the element was inserted.
6372 fn insert_accounted (
6473 & mut self ,
6574 x : Self :: T ,
0 commit comments