diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-04-02 14:27:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-02 14:27:52 +0200 |
| commit | cb81b41c9a474d403bd35fd2898ad226bc02657c (patch) | |
| tree | b2c1bb06618373efeb3603583c73cf31028c3e35 /src/libcore | |
| parent | 0f72ce1b271b40a5652049362e6aab5914f7b1d3 (diff) | |
| parent | 4582c14bd48c74521e549fafc1e4a7d30e2b7b85 (diff) | |
| download | rust-cb81b41c9a474d403bd35fd2898ad226bc02657c.tar.gz rust-cb81b41c9a474d403bd35fd2898ad226bc02657c.zip | |
Rollup merge of #70281 - xfix:infallible-hash, r=dtolnay
Implement Hash for Infallible https://www.reddit.com/r/rust/comments/fmllgx/never_crate_stable_alternative_to/ lists not implementing `Hash` as a reason for the `never` crate. I see no reason not to implement `Hash` for `Infallible`, so might as well do it. No changes necessary for `!`, because `!` already implements `Hash` (see https://github.com/rust-lang/rust/pull/51404).
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/convert/mod.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libcore/convert/mod.rs b/src/libcore/convert/mod.rs index 47ab8715cfa..eef9ee7cb00 100644 --- a/src/libcore/convert/mod.rs +++ b/src/libcore/convert/mod.rs @@ -41,6 +41,7 @@ #![stable(feature = "rust1", since = "1.0.0")] use crate::fmt; +use crate::hash::{Hash, Hasher}; mod num; @@ -746,3 +747,10 @@ impl From<!> for Infallible { x } } + +#[stable(feature = "convert_infallible_hash", since = "1.44.0")] +impl Hash for Infallible { + fn hash<H: Hasher>(&self, _: &mut H) { + match *self {} + } +} |
