diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-04-02 21:22:00 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-02 21:22:00 +0200 |
| commit | d63ddef8033b056b73efc4531769dca07e3a2f66 (patch) | |
| tree | 3c0aeb9834dbb99200c0e364e6eff70279520409 | |
| parent | 029cb1b13b6388b95e64e8996ec8b41a9f3cf16e (diff) | |
| parent | 54ab4258397030d71cbc5fbf279c0bc1861560aa (diff) | |
| download | rust-d63ddef8033b056b73efc4531769dca07e3a2f66.tar.gz rust-d63ddef8033b056b73efc4531769dca07e3a2f66.zip | |
Rollup merge of #123198 - krtab:build_hasher_default_const_new, r=Amanieu
Add fn const BuildHasherDefault::new See [tracking issue](https://github.com/rust-lang/rust/issues/123197) for justification.
| -rw-r--r-- | library/core/src/hash/mod.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/library/core/src/hash/mod.rs b/library/core/src/hash/mod.rs index ef0793a3e46..1c93a7b28fd 100644 --- a/library/core/src/hash/mod.rs +++ b/library/core/src/hash/mod.rs @@ -752,6 +752,18 @@ pub trait BuildHasher { #[stable(since = "1.7.0", feature = "build_hasher")] pub struct BuildHasherDefault<H>(marker::PhantomData<fn() -> H>); +impl<H> BuildHasherDefault<H> { + /// Creates a new BuildHasherDefault for Hasher `H`. + #[unstable( + feature = "build_hasher_default_const_new", + issue = "123197", + reason = "recently added" + )] + pub const fn new() -> Self { + BuildHasherDefault(marker::PhantomData) + } +} + #[stable(since = "1.9.0", feature = "core_impl_debug")] impl<H> fmt::Debug for BuildHasherDefault<H> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -778,7 +790,7 @@ impl<H> Clone for BuildHasherDefault<H> { #[stable(since = "1.7.0", feature = "build_hasher")] impl<H> Default for BuildHasherDefault<H> { fn default() -> BuildHasherDefault<H> { - BuildHasherDefault(marker::PhantomData) + Self::new() } } |
