I have a trait that looks like this:
pub trait Trait<K, V>
{
fn f<Q>(&self, k: &Q) -> Option<&V>
where K: Borrow<Q>;
}
When I try to write a function
fn create<K, V>(params here) -> Box<dyn Trait<K, V>> {
...
}
That instantiates one of the objects that satisfies the trait depending on parameters, I get the following error:
the trait `Trait` cannot be made into an object
|
= note: method `f` has generic type parameters
I don't really understand why this is happening, or how to fix it.