Skip to content

Commit

Permalink
Added Default implementation for generic BuildHasher
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaCappelletti94 authored and Licenser committed Sep 9, 2024
1 parent ccaf3f9 commit 5d630a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/h2b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ use crate::AHasherDefaultBuilder;
/// different numbers of sub streams.
///
/// Both the hasher and the sub stream size siaz can be customized, by default it uses `AHasherBuilder` and `M256`
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemDbg, mem_dbg::MemSize))]
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
pub struct HyperTwoBits<SKETCH: Sketch = M256, HASH: BuildHasher = AHasherDefaultBuilder> {
hash: HASH,
sketch: SKETCH,
count: u32,
t: u32,
}

impl<SKETCH: Sketch> Default for HyperTwoBits<SKETCH> {
impl<SKETCH: Sketch, H: Default + BuildHasher> Default for HyperTwoBits<SKETCH, H> {
fn default() -> Self {
Self {
hash: AHasherDefaultBuilder::default(),
hash: H::default(),
sketch: SKETCH::default(),
count: 0,
t: 1,
Expand Down
6 changes: 3 additions & 3 deletions src/h3b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ use crate::AHasherDefaultBuilder;
/// different numbers of sub streams.
///
/// Both the hasher and the sub stream size siaz can be customized, by default it uses `AHasherBuilder` and `M256`
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemDbg, mem_dbg::MemSize))]
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
pub struct HyperThreeBits<SKETCH: Sketch = M256, HASH: BuildHasher = AHasherDefaultBuilder> {
hash: HASH,
sketch: SKETCH,
count: u32,
t: u32,
}

impl<SKETCH: Sketch> Default for HyperThreeBits<SKETCH> {
impl<SKETCH: Sketch, H: Default + BuildHasher> Default for HyperThreeBits<SKETCH, H> {
fn default() -> Self {
Self {
hash: AHasherDefaultBuilder::default(),
hash: H::default(),
sketch: SKETCH::default(),
count: 0,
t: 1,
Expand Down

0 comments on commit 5d630a0

Please sign in to comment.