]> git.proxmox.com Git - rustc.git/blobdiff - library/core/src/mem/valid_align.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / library / core / src / mem / valid_align.rs
index 596a67f255a1bbcf3cbe003cbc8daab3903f57cf..fcfa95120df21e94d9c6f8c0b3f4c76026a0aa5b 100644 (file)
@@ -1,6 +1,6 @@
 use crate::convert::TryFrom;
 use crate::num::NonZeroUsize;
-use crate::{cmp, fmt, mem, num};
+use crate::{cmp, fmt, hash, mem, num};
 
 /// A type storing a `usize` which is a power of two, and thus
 /// represents a possible alignment in the rust abstract machine.
@@ -105,6 +105,13 @@ impl cmp::PartialOrd for ValidAlign {
     }
 }
 
+impl hash::Hash for ValidAlign {
+    #[inline]
+    fn hash<H: hash::Hasher>(&self, state: &mut H) {
+        self.as_nonzero().hash(state)
+    }
+}
+
 #[cfg(target_pointer_width = "16")]
 type ValidAlignEnum = ValidAlignEnum16;
 #[cfg(target_pointer_width = "32")]