4 ms·
Is there a reason why the loop and map don't result in the exact same code? It looks like the code does exactly the same thing and something the optimizer coul
by GuB-42 2y ago
Is there a reason why the loop and map don't result in the exact same code?
It looks like the code does exactly the same thing and something the optimizer could catch. Is is because of potential side effects? If not, maybe there is a ticket to open somewhere, if it isn't done already.
- skavi 2y agoThe FromIterator impl for Vec is specialized with unsafe code for these cases. FromIterator is the trait that the collect method uses. Specialization isn’t a stable feature in Rust, but is used extensively in the standard library.