Open
Description
Description
Currently, there are two separate implementations for iterating over a slice of u64
in big-endian and little-endian order, namely BitIteratorBE
and BitIteratorLE
. These implementations have similar functionalities but are implemented separately. This proposal suggests unifying them into a single implementation with an Endian
enum to denote whether the iteration should be in big-endian or little-endian order.
Proposed Changes
- Introduce an
Endian
enum with variantsbig
andlittle
. - Modify the iterator implementations to handle both big-endian and little-endian orders based on the value of the
Endian
enum.
Example Usage
use Endian::*;
// Usage example with the Endian enum
let mut iter = BitIterator::new(&data, Endian::big); // Big-endian order
let mut iter = BitIterator::new(&data, Endian::little); // Little-endian order
Benefits
- Simplifies the codebase by removing duplicate implementations.
- Provides a more consistent and unified interface.
- Allows for easy specification of the endianness using the
Endian
enum.
Metadata
Assignees
Labels
No labels