I am attempting to define a trait with generic parameters A,B, and I wish the trait to know that A must be a type which is convertible into B. (Specifically, I will define structs A,B myself and can implement a conversion logic). But how do I specify this in the trait definition? I looked into trait bounds
but it does not seem to have the answer.
pub trait MyTrait<A,B>{ // I wanted to add a constraint saying "A must be convertible into B"
fn createA() -> A;
fn createB() -> B{
let A = createA();
// I wish to convert A into B and return an instance of B here.
}
}
Thanks!