Hi there, I am trying to solve an issue where I have the same type parameter twice and rust is returning errors. My code looks like the following
trait MyTrait<OT> where OT: OtherTrait {
fn my_method<OOT>(input: OOT) -> OT where OOT: OtherOtherTrait;
}
struct MyStruct<OOT> where OOT: OtherOtherTrait {
field: OOT
}
impl<OOT> OtherTrait for MyStruct<OOT> where OOT: OtherOtherTrait {}
struct OtherStruct {}
impl<OOT> MyTrait<MyStruct<OOT>> for OtherStruct where OOT: OtherOtherTrait {
fn my_method<OOT>(input:OOT) -> MyStruct<OOT> where OOT: OtherOtherTrait {
MyStruct {
field: input
}
}
}
trait OtherTrait {}
trait OtherOtherTrait {}
Generally, I want my_method to return a struct that must have the OtherOtherTrait implemented on it. And the input for my_method will be a struct that also has the same trait applied to it. my_method will always be returning a struct with OtherTrait implemented on it, however it may not be dependant on the OtherOtherTrait.
In trying to fix this, I am getting errors about how the OOT from my_method has already been defined, and when I try renaming this to OOT2, I get errors about the return type, where it is expecting OOT but getting OOT2.
How do I tell rust that these are the same type parameters?
Thanks in advance!