Merged
Conversation
…ements - Introduced `Iter` and `IntoIter` types for iterating over timestamps in most-recently-used (MRU) order, enhancing usability. - Updated documentation to include detailed operation tables with method references, improving clarity and navigation. - Added examples for the new iterator methods, demonstrating their usage in practical scenarios. - Refined `FixedHistory` struct to derive `Copy`, ensuring lightweight copies in concurrent contexts. - Implemented `PartialEq`, `Eq`, and `Hash` traits for `FixedHistory`, allowing logical content comparison and hashability.
…provements - Introduced `EntryIter` for iterating over all entries in `FrequencyBuckets`, yielding tracked entries in unspecified order. - Updated documentation to include method references in the operations table, improving clarity and navigation. - Added examples for the new `into_inner` method, demonstrating its usage in practical scenarios. - Refined iterator implementations in `SlotArena` to enhance usability and maintain performance efficiency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Aligns
FixedHistory,SlotArena, andFrequencyBucketswith theRust API Guidelines —
specifically C-ITER-TY (iterator types are named structs, not
impl Iterator)and C-COMMON-TRAITS (standard trait impls).
FixedHistory<K>(src/ds/fixed_history.rs)Copy— the backing[u64; K]array is alwaysCopyPartialEq,Eq, andHashthat compare logical MRU contentrather than raw backing-array state (stale slots are invisible to equality/hashing)
iter() -> Iter<'_, K>for borrowed iteration in MRU orderIntoIteratorfor bothFixedHistory<K>(owned →IntoIter<K>) and&FixedHistory<K>(borrowed →Iter<'_, K>)ExactSizeIteratorSlotArena<T>(src/ds/slot_arena.rs)iter()now returns the namedIter<'_, T>struct instead ofimpl Iterator,making the type nameable by downstream code
FrequencyBuckets<K>/FrequencyBucketsHandle<H>(src/ds/frequency_buckets.rs)iter_entries()now returns the namedEntryIter<'_, K>structDebugonFrequencyBucketIdIterandFrequencyBucketEntryIterFrequencyBucketsHandle::into_inner()to unwrap the handle back to theinner
FrequencyBuckets<H>Related Issue
Fixes #
Type of Change
How Has This Been Tested?
New tests added in
fixed_history.rs:iter_yields_mru_orderiter_on_empty/iter_on_zero_capacityiter_after_wrapiter_partially_fillediter_count_matches_leniter_exact_sizeExactSizeIteratorcontractiter_matches_to_vec_mruto_vec_mruref_into_iter_for_loop&FixedHistoryinforloop without consumingowned_into_iter_for_loopIntoIteratorpartial_eq_*hash_equal_histories_same_hashhash_usable_in_hashmapHashMapkeycopy_produces_independent_valueCopydoesn't aliascopy_can_be_passed_by_valueTest environment:
Checklist
cargo fmtandcargo clippycargo test)Additional Notes
The
PartialEq/Hashimplementations onFixedHistorydeliberately iteratethrough
kth_most_recentrather than comparing the rawdataarray — twohistories with identical logical content but different cursor positions (e.g. one
that has wrapped) correctly compare equal and produce the same hash. This is
verified by
hash_equal_histories_same_hash.