https://github.com/louisgariepy/const-chunks
Extension trait to chunk iterators into const-length arrays.
https://github.com/louisgariepy/const-chunks
adapter chunk iterator rust
Last synced: 7 months ago
JSON representation
Extension trait to chunk iterators into const-length arrays.
- Host: GitHub
- URL: https://github.com/louisgariepy/const-chunks
- Owner: LouisGariepy
- License: apache-2.0
- Created: 2023-05-13T00:24:19.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-23T17:53:59.000Z (over 1 year ago)
- Last Synced: 2024-04-24T19:49:19.960Z (over 1 year ago)
- Topics: adapter, chunk, iterator, rust
- Language: Rust
- Homepage:
- Size: 35.2 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# `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](https://docs.rs/const-chunks/latest/const_chunks/) for more info.
```rust
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);
```## Safety
This crate uses unsafe to manipulate uninitialized memory.
To prevent undefined behavior, the code runs MIRI in CI. It's also well-documented and easy to audit.
Nevertheless, you should still consider this fact if you're trying to minimize unsafe dependencies.
## MSRV
This crate requires `rustc` version 1.65 or newer.
This crate's MSRV is enforced through the manifest's `rust-version` key.
## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or )
* MIT license ([LICENSE-MIT](LICENSE-MIT) or )at your option.
### Contribution
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.