|
|
|
|
|
by rkangel
2940 days ago
|
|
To explain this to people who don't know the background - this is about 'impl NameOfTrait' in the return position. It allows functions to return an object that provides a certain interface without specifying the actual type of that object. This was only previously true by wrapping it in a 'box', which meant a heap allocation and dynamic dispatch. The 'impl trait' provides static dispatch and no other overhead, so produces equivalent code to returning the type directly, but with all the abstraction flexibility that you want. |
|