Specialize on trait
As far as I can tell, the following will not compile:
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.
3 Replies
conditional conformance is coming down the pipeline and is available in nightly, the way you could kind of achieve this is parameterizing the struct with T as AnyType (or Variant[S1, S2]) then having specific functions require Self[S1] etc
look more in #nightly if this seems like the direction you want to go
@tkeitt
Thanks. I found it in the changelog. But your example is clearer.