Tracking issue for chunks_exact/_mut; slice chunks with exact size · Issue #47115 · rust-lang/rust (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@sdroege

Description

@sdroege

This is inspired by ndarray and generally seems to allow llvm to remove more bounds checks in the code using the iterator (because the slices will always be exactly the requested size), and doesn't require the caller to add additional checks.

A PR adding these for further discussion will come in a bit.

Open questions:

A function for getting access to the remainder exists on the iterator, similar to how `slice::Iter` and `slice::IterMut` give access to the tail (note: the remainder are the odd elements that don't completely fill a chunk, it's not the tail!)
**The majority of people (who spoke up here) seem to prefer the non-panicking behaviour**

- [x] Should it be called `exact_chunks` or `chunks_exact`? The former is how it's called in `ndarray`, the latter is [potentially more discoverable](https://github.com/rust-lang/rust/issues/47115#issuecomment-403090815) in e.g. IDEs.
**It was renamed to `chunks_exact`**