Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My understanding is that impl Iterator<Item = i32> in return position means that there is some single concrete type that implements the Iterator trait that we are simply not going to name. This way, the compiler can do dispatching statically. If different paths returned values with different types there wouldn't be just a single type that is known at compilation time. That is why the extra indirection via trait objects is required in the example.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: