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).
This commit is contained in:
commit
cb81b41c9a
@ -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 @@ fn from(x: !) -> Self {
|
||||
x
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "convert_infallible_hash", since = "1.44.0")]
|
||||
impl Hash for Infallible {
|
||||
fn hash<H: Hasher>(&self, _: &mut H) {
|
||||
match *self {}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user