File tree Expand file tree Collapse file tree 1 file changed +33
-3
lines changed Expand file tree Collapse file tree 1 file changed +33
-3
lines changed Original file line number Diff line number Diff line change 1
1
use num_traits:: { PrimInt , Unsigned , Zero , One } ;
2
2
use std:: ops:: { BitAnd } ;
3
3
4
+
5
+ trait BitWidth {
6
+ const BIT_WIDTH : usize ;
7
+ }
8
+
9
+ impl BitWidth for u128 {
10
+ const BIT_WIDTH : usize = 128 ;
11
+ }
12
+
13
+ impl BitWidth for u64 {
14
+ const BIT_WIDTH : usize = 64 ;
15
+ }
16
+
17
+ impl BitWidth for u32 {
18
+ const BIT_WIDTH : usize = 32 ;
19
+ }
20
+
21
+ impl BitWidth for u16 {
22
+ const BIT_WIDTH : usize = 16 ;
23
+ }
24
+
25
+ impl BitWidth for u8 {
26
+ const BIT_WIDTH : usize = 8 ;
27
+ }
28
+
29
+
4
30
#[ derive( Clone ) ]
5
- pub struct BitColumnMatrix32 {
6
- columns : [ u32 ; 32 ] ,
31
+ pub struct BitColumnMatrix < T >
32
+ where T : PrimInt + Unsigned + std:: marker:: Sized ,
33
+ {
34
+ columns : [ T ; std:: mem:: size_of :: < T > ( ) * 8 ] ,
7
35
}
8
36
9
- impl BitColumnMatrix32 {
37
+ impl < T > BitColumnMatrix < T >
38
+ where T : BitWidth ,
39
+ {
10
40
const WIDTH : usize = 32 ;
11
41
12
42
pub fn new ( init_data : & [ u32 ; 32 ] ) -> BitColumnMatrix32 {
You can’t perform that action at this time.
0 commit comments