|
|
|
|
|
by Manishearth
3468 days ago
|
|
I'm not really sure if that advice is accurate. For both iterators and futures, in most cases you will be returning a concrete type which can be named. You only really need to box it if you have a closure involved (and if you have a complicated adapter chain it becomes cleaner to box/impl trait it) E.g. in this case there's no specific compulsion to use a trait object. I wouldn't consider this to be a rule of thumb; it's more like "if you have trouble naming the return type try using Box<Trait>" |
|
The name of said type can get real hairy real fast, as well.