Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 54f28e9

Browse files
authoredApr 2, 2020
Rollup merge of rust-lang#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 rust-lang#51404).
2 parents 127a11a + 4582c14 commit 54f28e9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

‎src/libcore/convert/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#![stable(feature = "rust1", since = "1.0.0")]
4242

4343
use crate::fmt;
44+
use crate::hash::{Hash, Hasher};
4445

4546
mod num;
4647

@@ -746,3 +747,10 @@ impl From<!> for Infallible {
746747
x
747748
}
748749
}
750+
751+
#[stable(feature = "convert_infallible_hash", since = "1.44.0")]
752+
impl Hash for Infallible {
753+
fn hash<H: Hasher>(&self, _: &mut H) {
754+
match *self {}
755+
}
756+
}

0 commit comments

Comments
 (0)
Please sign in to comment.