File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -17,3 +17,4 @@ portaudio = "0.7"
1717[features ]
1818default = [" std" ]
1919std = []
20+ const_generics = []
Original file line number Diff line number Diff line change 1313#![ cfg_attr( not( feature = "std" ) , no_std) ]
1414#![ cfg_attr( not( feature = "std" ) , feature( alloc, core_intrinsics) ) ]
1515
16+ #![ cfg_attr( feature = "const_generics" , feature( const_generics) ) ]
17+
1618#[ cfg( feature = "std" ) ]
1719extern crate core;
1820
Original file line number Diff line number Diff line change @@ -92,6 +92,27 @@ impl<T> SliceMut for Vec<T> {
9292 }
9393}
9494
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" ) ) ]
95116macro_rules! impl_slice_for_arrays {
96117 ( $( $N: expr) * ) => {
97118 $(
@@ -115,6 +136,7 @@ macro_rules! impl_slice_for_arrays {
115136 } ;
116137}
117138
139+ #[ cfg( not( feature = "const_generics" ) ) ]
118140impl_slice_for_arrays ! {
119141 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
120142 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