Skip to content

hashers: derive Debug and Clone #39

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

Merged
merged 2 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

- Added `Debug` implementations to hashers.
- Added `Clone` implementations to hashers.

### Changed

- Updated the edition from 2015 to 2021.
Expand All @@ -16,7 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Removed the `byteorder` dependency.
- Removed the `BuildHasherDefault` type.
- This type existed because `core::hash::BuildHasherDefault` did not have a const constructor.
- As of 1.85 core::hash::BuildHasherDefault has a const constructor.
- As of 1.85 `core::hash::BuildHasherDefault` has a const constructor.

## [v0.3.1] - 2022-08-09

Expand Down
1 change: 1 addition & 0 deletions src/fnv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const PRIME: u32 = 0x1000193;
/// Specifically this implements the [FNV-1a hash].
///
/// [FNV-1a hash]: https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1a_hash
#[derive(Debug, Clone)]
pub struct FnvHasher {
state: u32,
}
Expand Down
6 changes: 4 additions & 2 deletions src/murmur3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ use core::slice;
use crate::Hasher as _;

/// 32-bit `MurmurHash3` hasher
#[derive(Debug, Clone)]
pub struct Murmur3Hasher {
buf: Buffer,
index: Index,
processed: u32,
state: State,
}

#[derive(Debug, Clone)]
struct State(u32);

#[derive(Clone, Copy)]
#[derive(Debug, Clone, Copy)]
#[repr(align(4))]
struct Buffer {
bytes: MaybeUninit<[u8; 4]>,
}

#[derive(Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq)]
enum Index {
_0,
_1,
Expand Down