Assigning additional traits to Variants
Is there a way to assign a trait to the
Variant
type? I'm specifically trying to use the __str__
method with List[Variant[types..]]
specifically.3 Replies
that much would probably be best done by wrapping the variant in your own inner type that knows how to branch across the member types
I don't think that the comptime stuff in mojo so far would be able to handle it for you yet
Alr thanks
Adding methods to existing types is a planned feature but not here yet so for now you'll have to do the wrapper type approach as previously mentioned or just make a standalone function