@@ -23,7 +23,9 @@ pub trait SliceExt {
23
23
/// let mut slice = [1, 2, 3];
24
24
/// let fail = slice.as_chunks_mut::<0>();
25
25
/// ```
26
- fn bitcoin_as_chunks_mut < const N : usize > ( & mut self ) -> ( & mut [ [ Self :: Item ; N ] ] , & mut [ Self :: Item ] ) ;
26
+ fn bitcoin_as_chunks_mut < const N : usize > (
27
+ & mut self ,
28
+ ) -> ( & mut [ [ Self :: Item ; N ] ] , & mut [ Self :: Item ] ) ;
27
29
}
28
30
29
31
impl < T > SliceExt for [ T ] {
@@ -40,11 +42,15 @@ impl<T> SliceExt for [T] {
40
42
// we're merely casting, so no aliasing issues here
41
43
// arrays of T have same alignment as T
42
44
// the resulting slice points within the obtained slice as was computed above
43
- let left = unsafe { core:: slice:: from_raw_parts ( left. as_ptr ( ) . cast :: < [ Self :: Item ; N ] > ( ) , chunks_count) } ;
45
+ let left = unsafe {
46
+ core:: slice:: from_raw_parts ( left. as_ptr ( ) . cast :: < [ Self :: Item ; N ] > ( ) , chunks_count)
47
+ } ;
44
48
( left, right)
45
49
}
46
50
47
- fn bitcoin_as_chunks_mut < const N : usize > ( & mut self ) -> ( & mut [ [ Self :: Item ; N ] ] , & mut [ Self :: Item ] ) {
51
+ fn bitcoin_as_chunks_mut < const N : usize > (
52
+ & mut self ,
53
+ ) -> ( & mut [ [ Self :: Item ; N ] ] , & mut [ Self :: Item ] ) {
48
54
#[ allow( clippy:: let_unit_value) ]
49
55
let _ = Hack :: < N > :: IS_NONZERO ;
50
56
@@ -55,15 +61,22 @@ impl<T> SliceExt for [T] {
55
61
// we're merely casting, so no aliasing issues here
56
62
// arrays of T have same alignment as T
57
63
// the resulting slice points within the obtained slice as was computed above
58
- let left = unsafe { core:: slice:: from_raw_parts_mut ( left. as_mut_ptr ( ) . cast :: < [ Self :: Item ; N ] > ( ) , chunks_count) } ;
64
+ let left = unsafe {
65
+ core:: slice:: from_raw_parts_mut (
66
+ left. as_mut_ptr ( ) . cast :: < [ Self :: Item ; N ] > ( ) ,
67
+ chunks_count,
68
+ )
69
+ } ;
59
70
( left, right)
60
71
}
61
72
}
62
73
63
74
struct Hack < const N : usize > ;
64
75
65
76
impl < const N : usize > Hack < N > {
66
- const IS_NONZERO : ( ) = { assert ! ( N != 0 ) ; } ;
77
+ const IS_NONZERO : ( ) = {
78
+ assert ! ( N != 0 ) ;
79
+ } ;
67
80
}
68
81
69
82
#[ cfg( test) ]
0 commit comments