diff --git a/src/as_bytes.rs b/src/as_bytes.rs index e76d2e2..b0397d6 100644 --- a/src/as_bytes.rs +++ b/src/as_bytes.rs @@ -1,4 +1,4 @@ -// Copyright 2015 blake2-rfc Developers +// Copyright 2016 blake2-rfc Developers // // Licensed under the Apache License, Version 2.0, or the MIT license &[u8]; fn as_mut_bytes(&mut self) -> &mut [u8]; } -impl AsBytes for [T] { +impl AsBytes for [T] { #[inline] fn as_bytes(&self) -> &[u8] { unsafe { - slice::from_raw_parts(self.as_ptr() as *const u8, self.len() * mem::size_of::()) + slice::from_raw_parts(self.as_ptr() as *const u8, + self.len() * mem::size_of::()) } } @@ -29,3 +32,12 @@ impl AsBytes for [T] { } } } + +unsafe impl Safe for u8 {} +unsafe impl Safe for u16 {} +unsafe impl Safe for u32 {} +unsafe impl Safe for u64 {} +unsafe impl Safe for i8 {} +unsafe impl Safe for i16 {} +unsafe impl Safe for i32 {} +unsafe impl Safe for i64 {} diff --git a/src/simdty.rs b/src/simdty.rs index eaa01f1..6a16fc8 100644 --- a/src/simdty.rs +++ b/src/simdty.rs @@ -1,4 +1,4 @@ -// Copyright 2015 blake2-rfc Developers +// Copyright 2016 blake2-rfc Developers // // Licensed under the Apache License, Version 2.0, or the MIT license { @@ -69,3 +71,9 @@ impl Simd4 { Simd4(e0, e1, e2, e3) } } + +unsafe impl Safe for Simd2 {} +unsafe impl Safe for Simd4 {} +unsafe impl Safe for Simd8 {} +unsafe impl Safe for Simd16 {} +unsafe impl Safe for Simd32 {}