Skip to content

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.

Notifications You must be signed in to change notification settings

JohnScience/collect_array_ext_trait

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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);
}

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages