I would like to know how to have the struct Interface
as a field in another struct when there is a type argument.
pub struct Interface<'a, 'b, 'c, DeviceT: Device + 'a> {}
pub struct Foo {
iface: Interface<'static, 'static, 'static, Device + 'static>,
}
pub trait Device {
type RxBuffer: AsRef<[u8]>;
type TxBuffer: AsRef<[u8]> + AsMut<[u8]>;
}
This results in the error:
error[E0191]: the value of the associated type `TxBuffer` (from the trait `Device`) must be specified
--> src/main.rs:4:49
|
4 | iface: Interface<'static, 'static, 'static, Device + 'static>,
| ^^^^^^^^^^^^^^^^ missing associated type `TxBuffer` value
error[E0191]: the value of the associated type `RxBuffer` (from the trait `Device`) must be specified
--> src/main.rs:4:49
|
4 | iface: Interface<'static, 'static, 'static, Device + 'static>,
| ^^^^^^^^^^^^^^^^ missing associated type `RxBuffer` value
What is the correct way of having interface
inside Foo
?