Add Iterator::array_chunks
(take N+1) by WaffleLapkin · Pull Request #100026 · rust-lang/rust (original) (raw)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I'll block the PR on this, but unwrap_err_unchecked
here scares me -- I added a note to the tracking issue.
My instinct for now is that %N
is definitely trustworthy, so that combined with take
is sufficient to say this is ok. But I'm still afraid, since it's not TrustedLen
, and wonder if someone can come up with an evil example here where it somehow gets a full chunk and thus is UB in safe code.
(At least the obvious things, like a len()
that always says usize
, is protected against because of the modulo.)