File tree Expand file tree Collapse file tree 3 files changed +20
-17
lines changed Expand file tree Collapse file tree 3 files changed +20
-17
lines changed Original file line number Diff line number Diff line change 2727use std:: mem;
2828use std:: slice;
2929
30- pub trait AsMutBytes {
30+ pub trait AsBytes {
31+ fn as_bytes ( & self ) -> & [ u8 ] ;
3132 fn as_mut_bytes ( & mut self ) -> & mut [ u8 ] ;
3233}
3334
34- macro_rules! as_mut_bytes_impl {
35- ( $t: ty) => {
36- impl AsMutBytes for $t {
37- #[ inline]
38- fn as_mut_bytes( & mut self ) -> & mut [ u8 ] {
39- unsafe {
40- slice:: from_raw_parts_mut(
41- self . as_mut_ptr( ) as * mut u8 ,
42- mem:: size_of:: <Self >( ) )
43- }
44- }
35+ impl < T > AsBytes for [ T ] {
36+ #[ inline]
37+ fn as_bytes ( & self ) -> & [ u8 ] {
38+ unsafe {
39+ slice:: from_raw_parts (
40+ self . as_ptr ( ) as * const u8 ,
41+ self . len ( ) * mem:: size_of :: < T > ( ) )
4542 }
4643 }
47- }
4844
49- as_mut_bytes_impl ! ( [ u32 ; 16 ] ) ;
50- as_mut_bytes_impl ! ( [ u64 ; 16 ] ) ;
45+ #[ inline]
46+ fn as_mut_bytes ( & mut self ) -> & mut [ u8 ] {
47+ unsafe {
48+ slice:: from_raw_parts_mut (
49+ self . as_mut_ptr ( ) as * mut u8 ,
50+ self . len ( ) * mem:: size_of :: < T > ( ) )
51+ }
52+ }
53+ }
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ macro_rules! blake2_impl {
4747 use std:: mem;
4848 use std:: slice;
4949
50- use $crate:: as_mut_bytes :: AsMutBytes ;
50+ use $crate:: as_bytes :: AsBytes ;
5151 use $crate:: bytes:: { MutableByteVector , copy_memory} ;
5252 use $crate:: constant_time_eq:: constant_time_eq;
5353 use $crate:: simd:: { Vector , $vec} ;
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ extern crate constant_time_eq;
3636
3737#[ cfg( feature = "simd" ) ] extern crate simdty;
3838
39- mod as_mut_bytes ;
39+ mod as_bytes ;
4040mod bytes;
4141mod simd;
4242
You can’t perform that action at this time.
0 commit comments