Skip to content

Commit f21759d

Browse files
authored
Rollup merge of rust-lang#123198 - krtab:build_hasher_default_const_new, r=Amanieu
Add fn const BuildHasherDefault::new See [tracking issue](rust-lang#123197) for justification.
2 parents 36b6f9b + 54ab425 commit f21759d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Diff for: library/core/src/hash/mod.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,18 @@ pub trait BuildHasher {
752752
#[stable(since = "1.7.0", feature = "build_hasher")]
753753
pub struct BuildHasherDefault<H>(marker::PhantomData<fn() -> H>);
754754

755+
impl<H> BuildHasherDefault<H> {
756+
/// Creates a new BuildHasherDefault for Hasher `H`.
757+
#[unstable(
758+
feature = "build_hasher_default_const_new",
759+
issue = "123197",
760+
reason = "recently added"
761+
)]
762+
pub const fn new() -> Self {
763+
BuildHasherDefault(marker::PhantomData)
764+
}
765+
}
766+
755767
#[stable(since = "1.9.0", feature = "core_impl_debug")]
756768
impl<H> fmt::Debug for BuildHasherDefault<H> {
757769
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -778,7 +790,7 @@ impl<H> Clone for BuildHasherDefault<H> {
778790
#[stable(since = "1.7.0", feature = "build_hasher")]
779791
impl<H> Default for BuildHasherDefault<H> {
780792
fn default() -> BuildHasherDefault<H> {
781-
BuildHasherDefault(marker::PhantomData)
793+
Self::new()
782794
}
783795
}
784796

0 commit comments

Comments
 (0)