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
sb
sb2mo ago
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
banananas
banananasOP2mo ago
Alr thanks
Ryulord
Ryulord2mo ago
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
Want results from more Discord servers?
Add your server