- // This expects to receive one and exactly one 64-bit value
- debug_assert!(bytes.len() == 8);
- unsafe {
- ptr::copy_nonoverlapping(&bytes[0] as *const u8 as *const u64, &mut self.value, 1)
- }
+ // This expects to receive exactly one 64-bit value, and there’s no realistic chance of
+ // that changing, but I don’t want to depend on something that isn’t expressly part of the
+ // contract for safety. But I’m OK with release builds putting everything in one bucket
+ // if it *did* change (and debug builds panicking).
+ debug_assert_eq!(bytes.len(), 8);
+ let _ = bytes.try_into()
+ .map(|array| self.value = u64::from_ne_bytes(array));