1- pub struct RowPins < ' a , MC : MatrixConfig + ' a > {
1+ pub struct RowPins < ' a , MC : MatrixConfig < ' a > + ' a > {
22 count : usize ,
33 conf : & ' a MC ,
44}
55
6- impl < ' a , MC : MatrixConfig + ' a > RowPins < ' a , MC > {
6+ impl < ' a , MC : MatrixConfig < ' a > > RowPins < ' a , MC > {
77 fn new ( conf : & ' a MC ) -> RowPins < ' a , MC > {
88 RowPins {
99 count : 0 ,
@@ -12,7 +12,7 @@ impl<'a, MC: MatrixConfig + 'a> RowPins<'a, MC> {
1212 }
1313}
1414
15- impl < ' a , MC : MatrixConfig > Iterator for RowPins < ' a , MC > {
15+ impl < ' a , MC : MatrixConfig < ' a > > Iterator for RowPins < ' a , MC > {
1616 type Item = MC :: InputPin ;
1717 fn next ( & mut self ) -> Option < Self :: Item > {
1818 if self . count == self . conf . get_num_rows ( ) {
@@ -25,12 +25,12 @@ impl<'a, MC: MatrixConfig> Iterator for RowPins<'a, MC> {
2525 }
2626}
2727
28- pub struct ColumnPins < ' a , MC : MatrixConfig + ' a > {
28+ pub struct ColumnPins < ' a , MC : MatrixConfig < ' a > + ' a > {
2929 count : usize ,
3030 conf : & ' a MC ,
3131}
3232
33- impl < ' a , MC : MatrixConfig + ' a > ColumnPins < ' a , MC > {
33+ impl < ' a , MC : MatrixConfig < ' a > > ColumnPins < ' a , MC > {
3434 fn new ( conf : & ' a MC ) -> ColumnPins < ' a , MC > {
3535 ColumnPins {
3636 count : 0 ,
@@ -39,7 +39,7 @@ impl<'a, MC: MatrixConfig + 'a> ColumnPins<'a, MC> {
3939 }
4040}
4141
42- impl < ' a , MC : MatrixConfig > Iterator for ColumnPins < ' a , MC > {
42+ impl < ' a , MC : MatrixConfig < ' a > > Iterator for ColumnPins < ' a , MC > {
4343 type Item = MC :: OutputPin ;
4444 fn next ( & mut self ) -> Option < Self :: Item > {
4545 if self . count == self . conf . get_num_columns ( ) {
@@ -52,22 +52,22 @@ impl<'a, MC: MatrixConfig> Iterator for ColumnPins<'a, MC> {
5252 }
5353}
5454
55- pub trait MatrixConfig {
55+ pub trait MatrixConfig < ' a > {
5656 type InputPin ;
5757 type OutputPin ;
5858
5959 fn get_num_rows ( & self ) -> usize ;
6060 fn get_num_columns ( & self ) -> usize ;
6161
62- fn get_row_pin ( & self , idx : usize ) -> Self :: InputPin ;
63- fn get_column_pin ( & self , idx : usize ) -> Self :: OutputPin ;
62+ fn get_row_pin ( & ' a self , idx : usize ) -> Self :: InputPin ;
63+ fn get_column_pin ( & ' a self , idx : usize ) -> Self :: OutputPin ;
6464
65- fn rows ( & self ) -> RowPins < Self >
65+ fn rows ( & ' a self ) -> RowPins < Self >
6666 where Self : Sized
6767 {
6868 RowPins :: new ( & self )
6969 }
70- fn columns ( & self ) -> ColumnPins < Self >
70+ fn columns ( & ' a self ) -> ColumnPins < Self >
7171 where Self : Sized
7272 {
7373 ColumnPins :: new ( & self )
@@ -80,7 +80,7 @@ mod tests {
8080 #[ test]
8181 fn basic ( ) {
8282 struct TestMatrixConfig { }
83- impl MatrixConfig for TestMatrixConfig {
83+ impl < ' a > MatrixConfig < ' a > for TestMatrixConfig {
8484 type InputPin = u32 ;
8585 type OutputPin = u32 ;
8686 fn get_num_rows ( & self ) -> usize {
@@ -89,10 +89,10 @@ mod tests {
8989 fn get_num_columns ( & self ) -> usize {
9090 3
9191 }
92- fn get_row_pin ( & self , idx : usize ) -> Self :: InputPin {
92+ fn get_row_pin ( & ' a self , idx : usize ) -> Self :: InputPin {
9393 idx as u32
9494 }
95- fn get_column_pin ( & self , idx : usize ) -> Self :: OutputPin {
95+ fn get_column_pin ( & ' a self , idx : usize ) -> Self :: OutputPin {
9696 idx as u32
9797 }
9898 }
0 commit comments