Q: Expressing associated type constraints


#1

Hi! Quick question: I want something like this:

trait Foo {
    type Associated: ops::Add<f64,Output=f64>;
}

But also include the constraint f64:Add<Associated,Output=f64> for symmetry. Is there a syntax for doing this?

Thanks!


#2
trait Foo
where
    f64: std::ops::Add<Self::Associated, Output = f64>,
{
    type Associated: std::ops::Add<f64, Output = f64>;
}

#3

Thanks!