3 ms·
With Any you can downcast to concrete types, but not to other trait objects. There is no fundamental reason why this shouldn't be allowed AFAICT though, so we m
by Manishearth 10y ago
With Any you can downcast to concrete types, but not to other trait objects. There is no fundamental reason why this shouldn't be allowed AFAICT though, so we might be able to add it. You can currently double-box things to do it, and probably write a library that makes this easy, but it's much nicer to have the language do it efficiently in cases like this.
I wasn't aware that you could do that in swift, that sounds quite powerful and useful!