3 ms·
The implementation being completely rewritten is fine. Nobody should rely on internal fields or details of function calls. The implementation changing to be a
by Dylan16807 11y ago
The implementation being completely rewritten is fine. Nobody should rely on internal fields or details of function calls.
The implementation changing to be asymptotically worse is not fine.
Also they could have changed the garbage collector to make both cases perform well.
Edit: And the comments you linked have a good point made in them, if you don't assume some bounds on how long a function is going to take, you can't call it ever. substr is not a function that's supposed to be forbidden.
- lmm 11y agoAsymptotics aren't a practical bound on anything - a function documented as being O(1) could still take ten thousand years. In practice outside of hard realtime systems all functions are best-effort and we confirm acceptable performance empirically rather than having any explicit guarantees. I do think a language that made it explicit exactly how long any given function would take would be a good thing, but that would be a much bigger undertaking than Rust's borrow checker.