collect_array_ext_trait

Crates.iocollect_array_ext_trait
lib.rscollect_array_ext_trait
version0.2.0
sourcesrc
created_at2024-01-16 06:25:37.691324
updated_at2024-01-16 07:59:53.948425
descriptionCollect an iterator into an array.
homepage
repositoryhttps://github.com/JohnScience/collect_array_ext_trait
max_upload_size
id1101338
size4,516
Dmitrii - Demenev (JohnScience)

documentation

https://docs.rs/collect_array_ext_trait

README

collect_array_ext_trait

Crates.io Downloads Documentation License Dependency Status

This is a simple library for collecting an instance of It: std::iter::Iterator<Item=T> into an array [T; N] where N is the presumed length of the iterator.

Example

use collect_array_ext_trait::CollectArray;

fn main() {
    let arr = (0..5).collect_array::<5>().unwrap();
    let mut iter = arr.iter().copied();
    assert_eq!(iter.next(), Some(0));
    assert_eq!(iter.next(), Some(1));
    assert_eq!(iter.next(), Some(2));
    assert_eq!(iter.next(), Some(3));
    assert_eq!(iter.next(), Some(4));
    assert_eq!(iter.next(), None);
}
Commit count: 0

cargo fmt