I am trying to implement a trait using a "map" concept. I've came up with the following minimal example:
trait Value<T> {
fn get(&self) -> T;
}
struct ValueMap<S, F> {
s: S,
f: F,
}
impl<T, U, S: Value<T>, F: Fn(T) -> U> Value<U> for ValueMap<S, F> {
fn get(&self) -> U {
(self.f)(self.s.get())
}
}
I get the error the type parameterTis not constrained by the impl trait, self type, or predicates.
How may I implement the Value trait for my ValueMap struct when F is a function that maps the value S to something else?
Remarks: I don't have this issue when I use associated types on Value. But the concepts are still a bit blurry for me.