Skip to content

Commit

Permalink
Derive Debug for some types so they can be used in Debug derived …
Browse files Browse the repository at this point in the history
…structs.

Ex.:

```rust
 #[derive(Debug)]
 pub struct AccessUnitIter<'a> {
     headers_r: Option<BitReader<Cursor<&'a [u8]>, BigEndian>>,
     [...]
 }

```
  • Loading branch information
fengalin committed Dec 2, 2023
1 parent b0d8304 commit f6adcba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ pub trait Endianness: Sized {
}

/// Big-endian, or most significant bits first
#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub struct BigEndian;

/// Big-endian, or most significant bits first
Expand Down Expand Up @@ -523,7 +523,7 @@ impl Endianness for BigEndian {
}

/// Little-endian, or least significant bits first
#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub struct LittleEndian;

/// Little-endian, or least significant bits first
Expand Down Expand Up @@ -673,7 +673,7 @@ impl Endianness for LittleEndian {

/// A queue for efficiently pushing bits onto a value
/// and popping them off a value.
#[derive(Clone, Default)]
#[derive(Clone, Debug, Default)]
pub struct BitQueue<E: Endianness, N: Numeric> {
phantom: PhantomData<E>,
value: N,
Expand Down
3 changes: 2 additions & 1 deletion src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ pub trait HuffmanRead<E: Endianness> {
/// This will read exactly as many whole bytes needed to return
/// the requested number of bits. It may cache up to a single partial byte
/// but no more.
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct BitReader<R: io::Read, E: Endianness> {
reader: R,
bitqueue: BitQueue<E, u8>,
Expand Down Expand Up @@ -1033,6 +1033,7 @@ pub trait ByteRead {
/// For reading aligned bytes from a stream of bytes in a given endianness.
///
/// This only reads aligned values and maintains no internal state.
#[derive(Debug)]
pub struct ByteReader<R: io::Read, E: Endianness> {
phantom: PhantomData<E>,
reader: R,
Expand Down

0 comments on commit f6adcba

Please sign in to comment.