Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify BitIteratorBE and BitIteratorLE with an Endian enum #785

Open
tcoratger opened this issue Feb 20, 2024 · 0 comments
Open

Unify BitIteratorBE and BitIteratorLE with an Endian enum #785

tcoratger opened this issue Feb 20, 2024 · 0 comments

Comments

@tcoratger
Copy link
Contributor

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant