3 ms·
Due to lifetime elision you can mostly skip lifetimes if you leave a bit of performance on the table.
by ViewTrick1002 10mo ago
Due to lifetime elision you can mostly skip lifetimes if you leave a bit of performance on the table.
- bluehex 10mo agoHow does lifetime elision affect performance? I thought the compiler just inferred lifetimes that you would have had to manually annotate. Naively, it seems to me that the performance should be identical.
- steveklabnik 10mo agoStrictly speaking, elision just adds lifetimes based on common patterns, so yes, it wouldn't directly affect performance. I believe your parent is implying that if you skip using a lifetime and do something else instead to make it easier, that may be less performant.
- adastra22 10mo agoI think his point is the lifetime you’d put there is identical to the lifetime that is inferred/elided. So there is literally no difference.
- steveklabnik 10mo agoI thought they meant the case where you go "ugh, I don't want to write a lifetime here" and then change your code, because you have to. If you don't have to, then yes, there's literally no difference.
- ViewTrick1002 10mo agoExactly. Cloning values, collecting iterators into Vecs and then continue the transformation rather than keeping it lazy all the way through. Skipping structs/enums with references.