File tree 3 files changed +25
-0
lines changed
3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -17,3 +17,4 @@ portaudio = "0.7"
17
17
[features ]
18
18
default = [" std" ]
19
19
std = []
20
+ const_generics = []
Original file line number Diff line number Diff line change 13
13
#![ cfg_attr( not( feature = "std" ) , no_std) ]
14
14
#![ cfg_attr( not( feature = "std" ) , feature( alloc, core_intrinsics) ) ]
15
15
16
+ #![ cfg_attr( feature = "const_generics" , feature( const_generics) ) ]
17
+
16
18
#[ cfg( feature = "std" ) ]
17
19
extern crate core;
18
20
Original file line number Diff line number Diff line change @@ -92,6 +92,27 @@ impl<T> SliceMut for Vec<T> {
92
92
}
93
93
}
94
94
95
+ #[ cfg( feature = "const_generics" ) ]
96
+ impl < T , const N : usize > Slice for [ T ; N ] {
97
+ type Element = T ;
98
+ #[ inline]
99
+ fn slice ( & self ) -> & [ Self :: Element ] {
100
+ & self [ ..]
101
+ }
102
+ }
103
+ #[ cfg( feature = "const_generics" ) ]
104
+ impl < T , const N : usize > SliceMut for [ T ; N ] {
105
+ #[ inline]
106
+ fn slice_mut ( & mut self ) -> & mut [ Self :: Element ] {
107
+ & mut self [ ..]
108
+ }
109
+ }
110
+ #[ cfg( feature = "const_generics" ) ]
111
+ impl < T , const N : usize > FixedSizeArray for [ T ; N ] {
112
+ const LEN : usize = N ;
113
+ }
114
+
115
+ #[ cfg( not( feature = "const_generics" ) ) ]
95
116
macro_rules! impl_slice_for_arrays {
96
117
( $( $N: expr) * ) => {
97
118
$(
@@ -115,6 +136,7 @@ macro_rules! impl_slice_for_arrays {
115
136
} ;
116
137
}
117
138
139
+ #[ cfg( not( feature = "const_generics" ) ) ]
118
140
impl_slice_for_arrays ! {
119
141
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
120
142
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
You can’t perform that action at this time.
0 commit comments