Hello,
I'm struggling to find a way to write some stuff with generics, I hope I can get some help here
I have the following struct:
pub struct ControlInterface<RESX, CSX, DCX, WRX, RDX, DB> {
resx: Option<RESX>,
csx: Option<CSX>,
dcx: DCX,
wrx: WRX,
rdx: RDX,
db: [DB; 8],
}
impl<RESX, CSX, DCX, WRX, RDX, DB> ControlInterface<RESX, CSX, DCX, WRX, RDX, DB>
where
RESX: hal::digital::v2::OutputPin,
CSX: hal::digital::v2::OutputPin,
DCX: hal::digital::v2::OutputPin,
WRX: hal::digital::v2::OutputPin,
RDX: hal::digital::v2::OutputPin,
DB: hal::digital::v2::OutputPin,
RESX::Error: Debug,
CSX::Error: Debug,
DCX::Error: Debug,
WRX::Error: Debug,
RDX::Error: Debug,
DB::Error: Debug,
{
...
}
and I have a Command
enum that I want to implement a function which takes a ControlInterface
argument:
pub enum Command {
Command1,
Command2,
}
impl<RESX, CSX, DCX, WRX, RDX, DB> Command<RESX, CSX, DCX, WRX, RDX, DB> {
fn send(self, ctrl: &ControlInterface<RESX, CSX, DCX, WRX, RDX, DB>) {
...
}
}
With the code I posted I get the following error:
error[E0107]: wrong number of type arguments: expected 0, found 6
--> src/ili9486/command.rs:59:44
|
59 | impl<RESX, CSX, DCX, WRX, RDX, DB> Command<RESX, CSX, DCX, WRX, RDX, DB> {
| ^^^^ ^^^ ^^^ ^^^ ^^^ ^^ unexpected type argument
| | | | | |
| | | | | unexpected type argument
| | | | unexpected type argument
| | | unexpected type argument
| | unexpected type argument
| unexpected type argument
I already tried different permutations of <...>
stuff, but I can't make it work. What am I missing here? I also tried removing the <...>
stuff (btw, what do you call the <...>
stuff?), and it doesn't work either:
impl Command {
fn send(self, ctrl: &ControlInterface) {
}
}
that gives:
error[E0107]: wrong number of type arguments: expected 6, found 0
--> src/ili9486/command.rs:60:26
|
60 | fn send(self, ctrl: &ControlInterface) {
| ^^^^^^^^^^^^^^^^ expected 6 type arguments