]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #47126 - sdroege:exact-chunks, r=bluss
authorkennytm <kennytm@gmail.com>
Mon, 15 Jan 2018 08:55:28 +0000 (16:55 +0800)
committerkennytm <kennytm@gmail.com>
Mon, 15 Jan 2018 10:49:31 +0000 (18:49 +0800)
commit5d0474ad73f2d9268f387726723fff44b88df3f7
treecf53cdd7104281472d4d80bfe20799063ca5d8d5
parent06112abd5f170e9f1ee06e212acb31976d6bb7c4
parent5f4fc8214279f2ffadbf2cc3a4c22b748c17bd15
Rollup merge of #47126 - sdroege:exact-chunks, r=bluss

Add slice::ExactChunks and ::ExactChunksMut iterators

These guarantee that always the requested slice size will be returned
and any leftoever elements at the end will be ignored. It allows llvm to
get rid of bounds checks in the code using the iterator.

This is inspired by the same iterators provided by ndarray.

Fixes https://github.com/rust-lang/rust/issues/47115

I'll add unit tests for all this if the general idea and behaviour makes sense for everybody.
Also see https://github.com/rust-lang/rust/issues/47115#issuecomment-354715511 for an example what this improves.
src/liballoc/slice.rs
src/liballoc/tests/slice.rs
src/libcore/slice/mod.rs
src/libcore/tests/slice.rs