X-Git-Url: https://git.chrismorgan.info/anymap/blobdiff_plain/b549457d628fb178f6d700d85800f3ab63482d63..6dab74b72178bb02bd26a8bcaf3cf588997d7800:/src/raw.rs?ds=inline diff --git a/src/raw.rs b/src/raw.rs index 7d53783..dbd5e2c 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -7,9 +7,9 @@ use std::borrow::Borrow; use std::collections::hash_map::{self, HashMap}; use std::hash::Hash; use std::hash::{Hasher, BuildHasherDefault}; +#[cfg(test)] use std::mem; use std::ops::{Index, IndexMut}; -use std::ptr; use any::{Any, UncheckedAnyExt}; @@ -22,10 +22,11 @@ impl Hasher for TypeIdHasher { #[inline] fn write(&mut self, bytes: &[u8]) { // This expects to receive one and exactly one 64-bit value - debug_assert!(bytes.len() == 8); - unsafe { - ptr::copy_nonoverlapping(mem::transmute(&bytes[0]), &mut self.value, 1) - } + assert!(bytes.len() == 8); + self.value = u64::from(bytes[0]) | u64::from(bytes[1]) << 8 | + u64::from(bytes[2]) << 16 | u64::from(bytes[3]) << 24 | + u64::from(bytes[4]) << 32 | u64::from(bytes[5]) << 40 | + u64::from(bytes[6]) << 48 | u64::from(bytes[7]) << 56; } #[inline] @@ -69,13 +70,6 @@ impl Clone for RawMap where Box: Clone { } } -impl Default for RawMap { - #[inline] - fn default() -> RawMap { - RawMap::new() - } -} - impl_common_methods! { field: RawMap.inner; new() => HashMap::with_hasher(Default::default());