Hi,
I have a trait "NumberSystem" typically representing SIMD vectors of different lengths and types. It has a type "Scalar" that represents the underlying number, i.e.
trait NumberSystem: LotsOfStuff {
type S: Scalar;
...
}
Now i also have a struct (interpolation grid) which only is distinct based on the Scalar type:
struct Grid<S: Scalar> {
data: Vec<S>
}
However, i want to have a method on "Grid" that allows me to be called with a value of any "NumberSystem" that has a scalar that matches the scalar of the Grid, i.e. something like:
impl<S> Grid<S> where S: Scalar {
pub fn lookup<N>(x: N) -> N
where N: NumberSystem,
N::S === S // THIS IS THE PROBLEM
{...}
}
Now, I struggle to express that requirement in the lookup function, that N::S of the generic on the function should equal the concrete S in the Grid struct.
Is this even possible to express?
Thanks in advance