3 ms·
Possible I missed it when I read it. Would need the author to indicate whether or not it was edited. Yes, idiomatic Rust can cause a number of bounds checks to
by vlovich123 3y ago
Possible I missed it when I read it. Would need the author to indicate whether or not it was edited.
Yes, idiomatic Rust can cause a number of bounds checks to be elided when using iterators. Typically that's when you have all the data that you need to process up front. When you don't have that ability (e.g. data is being fed in piecemeal and you're copying into a temporary buffer), the bounds checking elision is something you need to do yourself.
- cmrx64 3y agocan you elaborate? rust iterators seem quite capable of streaming in the fashion you suggest.
- vlovich123 3y agoIf I have a buffer in a library and the external API is “append to buffer”, each append will do a bounds check. I’m not aware of an iterator API would work especially considering that the iterator would hold ownership of the buffer which would be incompatible with the call flow returning to the user after the append.