Using structs that inherit from a specific trait as a type?
If you have a trait and a struct that inherits from it, could you use that trait's children as a type in, for example, a list? E.g.:
7 Replies
What happens when you try it?
If i just put the name of the trait i get this:
This would depend on
dyn
/virtual
or something in order to work, you might be able to do something with Object? But it wouldn't be as ergonomic as you'd hope
I don't want to say without evidence that that feature isn't in yet, but I think that's still waiting
(getting that to work pretty much requires either vtables or some global transformation on top of sum types, neither of which Mojo has yet)Ok... i'll see what i can do with that
yeah, sorry, I know that feature is pretty significant hole at the moment
Yeah it is :/
i ended up trying smth with
object
but it throws an error when i try this:
Trait object is not available yet.