Hello!
I have a problem with generics in Rust. I would like to add input to the vector.
Example 1:
[..]
let d_in1 = gpiod.pd7.into_floating_input(&mut gpiod.crl);
let d_in2 = gpiod.pd6.into_floating_input(&mut gpiod.crl);
let v = [d_in1, d_in2];
Error:
|
200 | let v = [d_in1, d_in2];
| ^^^^^ expected `7`, found `6`
|
= note: expected struct `stm32f1xx_hal::gpio::Pin<_, _, 7>`
found struct `stm32f1xx_hal::gpio::Pin<_, _, 6>`
Example 2:
[...]
let d_in1 = gpiod.pd7.into_floating_input(&mut gpiod.crl);
let d_in2 = gpiod.pd6.into_floating_input(&mut gpiod.crl);
let v = heapless::Vec::new();
v.push(d_in1);
v.push(d_in2);
Error:
203 | v.push(d_in1);
| - ----- this argument has type `stm32f1xx_hal::gpio::Pin<'D', 7>`...
| |
| ... which causes `v` to have type `Vec<stm32f1xx_hal::gpio::Pin<'D', 7>, _>`
204 | v.push(d_in2);
| ---- ^^^^^ expected `7`, found `6`
| |
| arguments to this method are incorrect
|
= note: expected struct `stm32f1xx_hal::gpio::Pin<_, _, 7>`
found struct `stm32f1xx_hal::gpio::Pin<_, _, 6>`
help: the return type of this call is `stm32f1xx_hal::gpio::Pin<'D', 6>` due to the type of the argument passed
--> app/src/main.rs:204:17
|
204 | v.push(d_in2);
| ^^^^^^^-----^
| |
| this argument influences the return type of `push`
Hello! I have a problem with generics in Rust. I would like to add input to the vector.
Example 1:
Error:
Example 2:
Error:
How to fix it?