ModularM
Modular2y ago
7 replies
tkeitt

Specialize on trait

As far as I can tell, the following will not compile:
trait T1:
    pass

trait T2:
    pass

struct S[T: T1]:
    pass

struct S[T: T2]:
    pass

Is the intention to allow this sort of type specialization in the future? I have a workaround using static methods for compile-time branching. However, it requires the definition of a trait that is the superset of the two cases and so each has to fulfill functions that the (sub-)trait does not require.
Was this page helpful?