Skip to content

Commit 2dddcdc

Browse files
committed
📝 Update docs
1 parent 44acf33 commit 2dddcdc

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ As this library provides a procedural macro, it has no runtime dependencies and
1212
- Compile-time checks for type and field sizes
1313
- Rust-analyzer/docrs friendly (carries over docs to accessor functions)
1414
- Exports field offsets and sizes as constants (useful for const asserts)
15-
- Generation of `Default`, `fmt::Debug`, or `defmt::Format` traits
15+
- Optional generation of `Default`, `Clone`, `Debug`, `Hash`, or `defmt::Format` traits
1616
- Custom internal representation (endianness)
1717

1818
## Usage
@@ -435,9 +435,23 @@ struct DefmtExample {
435435
}
436436
```
437437

438-
### Conditionally Enable `new`/`Clone`/`Debug`/`Default`/`defmt::Format`
438+
### Support for `std::hash::Hash`
439439

440-
Instead of booleans, you can specify `cfg(...)` attributes for `new`, `clone`, `debug`, `default` and `defmt`:
440+
This macro can also implement `Hash`, which ignores any padding when hashing.
441+
442+
```rust
443+
use bitfield_struct::bitfield;
444+
445+
#[bitfield(u64, hash = true)]
446+
struct HashExample {
447+
__ignored: u32,
448+
data: u32,
449+
}
450+
```
451+
452+
### Conditionally Enable `new`/`Clone`/`Debug`/`Default`/`defmt::Format`/`Hash`
453+
454+
Instead of booleans, you can specify `cfg(...)` attributes for `new`, `clone`, `debug`, `default`, `defmt` and `hash`:
441455

442456
```rust
443457
use bitfield_struct::bitfield;

tests/test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,6 @@ fn hash() {
636636
use std::hash::{Hash, Hasher};
637637

638638
#[bitfield(u32, hash = true)]
639-
#[derive(PartialEq, Eq)]
640639
struct MyBitfield {
641640
data: u16,
642641
__: u8,

0 commit comments

Comments
 (0)