Skip to content

Unify BitIteratorBE and BitIteratorLE with an Endian enum #785

Open
@tcoratger

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

  1. Introduce an Endian enum with variants big and little.
  2. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions