So I tried to rewrite this protocol in Rust:
protocol P1 {
associatedtype R : P1
associatedtype S : P1
where S.S.S.S == Self,
S.S.R.S.S.R == Self,
R.S.R.S.R.S == Self
}
Conversation
Here is what I came up with:
trait P1 {
type S : P1<S = Self::SS>;
type SS : P1<SS = Self, R = Self::SSR>;
type SSR : P1<SSR = Self>;
type R : P1<S = Self::RS>;
type RS : P1<RS = Self::RSRS>;
type RSRS : P1<RS = Self>;
}
Is there a better way?
1
1
I'm pretty sure `where` clauses were always meant to have `==` constraints, but I don't know why they were never implemented. See the original RFC: rust-lang.github.io/rfcs/0135-wher
fn sum<I:Iterator>(i: I) -> int
where I::E == int
{
...
}
1
Like, you can put `where` clauses on associated types, but you just can't express equality constraints in them atm. Dunno any shorter ways to express what you want, alas. :(

