Is there a way to force the algebraic type of an associated type of e.g. a trait:

trait Foo { type Thingamabob; // <- this shall be an enum, any enum, but never a struct. } 

I think that the rust type system currently cannot express this, but maybe someone knows a cool trick I didn't think of.

One could use a derive macro, which is only derivable for enums as a marker, but I don't want to force the user to put #[derive(Enum)] on all their enums.

8 posts - 6 participants

Read full topic