1
lorentz
212d

I've been trying to define a trait `Inherits<T>`, a trait `Extends{ type Parent }` and an arbitrary amount of scaffolding around it such that

- the scaffolding for a given type only has to acknowledge that type, its parent and the types of which it is a parent
- `T: Inherits<U>` if a chain of `Extends` leads from `T` to `U`

I suspect that this is impossible, but I'd seen Rust traits bent to do crazier things, so if you know of such a system or can come up with a way to implement it despite the orphan rules, I'd be over the moon.

Comments
  • 0
    If you want to take a crack at this, take a look at the pattern below, the solution would almost definitely have to employ a modified version of it. The article is a step-by-step explainer written by me, but the original forum question with two variants of the pattern is linked in the first paragraph.

    https://lbfalvy.com/blog/...
  • 0
    very frustratingly, it looks like this becomes very easy via any single one of the famous pending trait features; negative statements, overrides, const generic conditions...

    I have to check if it works via GATs by some miracle, although I bet they have a mighty convenient limitation to avoid it.
Add Comment