Skip to content

Commit 9fa28e7

Browse files
newAMeldruin
authored andcommitted
BuildHasherDefault: remove
This type existed because core::hash::BuildHasherDefault did not have a const constructor. As of 1.85 core::hash::BuildHasherDefault has a const constructor.
1 parent d5dfd1f commit 9fa28e7

File tree

2 files changed

+3
-69
lines changed

2 files changed

+3
-69
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
### Removed
1515

1616
- Removed the `byteorder` dependency.
17+
- Removed the `BuildHasherDefault` type.
18+
- This type existed because `core::hash::BuildHasherDefault` did not have a const constructor.
19+
- As of 1.85 core::hash::BuildHasherDefault has a const constructor.
1720

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

src/lib.rs

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
//! Since it extends `core::hash::Hasher`, `Hasher` can be used with any type which implements the
1717
//! standard `Hash` trait.
1818
//!
19-
//! This crate also adds a version of `BuildHasherDefault` with a const constructor, to work around
20-
//! the `core` version's lack of one.
21-
//!
2219
//! [`core::hash`]: https://doc.rust-lang.org/std/hash/index.html
2320
//! [`finish32`]: crate::Hasher::finish32
2421
//!
@@ -37,10 +34,6 @@
3734
//!
3835
//! The trait bound `H: hash32::Hasher` is *more* restrictive as it only accepts 32-bit hashers.
3936
//!
40-
//! The `BuildHasherDefault<H>` type implements the `core::hash::BuildHasher` trait so it can
41-
//! construct both 32-bit and 64-bit hashers. To constrain the type to only produce 32-bit hasher
42-
//! you can add the trait bound `H::Hasher: hash32::Hasher`
43-
//!
4437
//! # MSRV
4538
//!
4639
//! This crate is guaranteed to compile on latest stable Rust. It *might* compile on older
@@ -55,74 +48,12 @@
5548
)]
5649
#![no_std]
5750

58-
use core::fmt;
59-
use core::hash::BuildHasher;
60-
use core::marker::PhantomData;
61-
6251
pub use crate::fnv::Hasher as FnvHasher;
6352
pub use crate::murmur3::Hasher as Murmur3Hasher;
6453

6554
mod fnv;
6655
mod murmur3;
6756

68-
/// A copy of [`core::hash::BuildHasherDefault`][0], but with a const constructor.
69-
///
70-
/// This will eventually be deprecated once the version in `core` becomes const-constructible
71-
/// (presumably using `const Default`).
72-
///
73-
/// [0]: https://doc.rust-lang.org/core/hash/struct.BuildHasherDefault.html
74-
pub struct BuildHasherDefault<H> {
75-
_marker: PhantomData<H>,
76-
}
77-
78-
impl<H> Default for BuildHasherDefault<H> {
79-
fn default() -> Self {
80-
Self {
81-
_marker: PhantomData,
82-
}
83-
}
84-
}
85-
86-
impl<H> Clone for BuildHasherDefault<H> {
87-
fn clone(&self) -> Self {
88-
Self::default()
89-
}
90-
}
91-
92-
impl<H> PartialEq for BuildHasherDefault<H> {
93-
fn eq(&self, _other: &Self) -> bool {
94-
true
95-
}
96-
}
97-
98-
impl<H> Eq for BuildHasherDefault<H> {}
99-
100-
impl<H> fmt::Debug for BuildHasherDefault<H> {
101-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
102-
f.pad("BuildHasherDefault")
103-
}
104-
}
105-
106-
impl<H> BuildHasherDefault<H> {
107-
/// `const` constructor
108-
pub const fn new() -> Self {
109-
Self {
110-
_marker: PhantomData,
111-
}
112-
}
113-
}
114-
115-
impl<H> BuildHasher for BuildHasherDefault<H>
116-
where
117-
H: Default + core::hash::Hasher,
118-
{
119-
type Hasher = H;
120-
121-
fn build_hasher(&self) -> Self::Hasher {
122-
H::default()
123-
}
124-
}
125-
12657
/// An extension of [core::hash::Hasher][0] for hashers which use 32 bits.
12758
///
12859
/// For hashers which implement this trait, the standard `finish` method should just return a

0 commit comments

Comments
 (0)