Crates.io | const-chunks |
lib.rs | const-chunks |
version | 0.3.0 |
source | src |
created_at | 2023-05-13 00:45:46.935837 |
updated_at | 2023-10-04 20:41:18.934138 |
description | Extension trait to chunk iterators into const-length arrays. |
homepage | |
repository | https://github.com/LouisGariepy/const-chunks |
max_upload_size | |
id | 863425 |
size | 28,199 |
const-chunks
This crate provides a #![no_std]
-compatible extension trait that lets you chunk iterators into constant-length arrays using const
generics.
See the docs for more info.
use const_chunks::IteratorConstChunks;
let mut iter = vec![1, 2, 3, 4, 5].into_iter().const_chunks::<2>();
assert_eq!(iter.next(), Some([1,2]));
assert_eq!(iter.next(), Some([3,4]));
assert_eq!(iter.next(), None);
let mut remainder = iter.into_remainder().unwrap();
assert_eq!(remainder.next(), Some(5));
assert_eq!(remainder.next(), None);
This crate uses unsafe to manipulate uninitialized memory.
To prevent undefined behaviour, the code runs MIRI in CI, and is both very short and easy to audit.
Nevertheless, you should still consider this fact if you're trying to minimize unsafe dependencies.
This crate requires rustc
version 1.65 or newer.
This crate's MSRV is enforced through the manifest's rust-version
key.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.