Array Tools

A little collection of array-related utils aiming to make life easier.

Stability warning

Requires nightly.

Consider this crate experimental. Some (all?) of currently provided features are most likely will be integrated into rust's core/std library sooner or later, and with arrival of const generics public interfaces are most likely will be changed.

Features

Examples

```rust use array_tools::{self, ArrayIntoIterator};

// Array initialization with iterator. let array1: [u64; 7] = arraytools::tryinitfromiterator(0u64..17).unwrap();

assert_eq!(array1, [0, 1, 2, 3, 4, 5, 6]);

// Array initialization with function (w/o index). let mut value = 0u64;

let array2: [u64; 7] = arraytools::initwith(|| { let tmp = value; value += 1; tmp });

assert_eq!(array2, [0, 1, 2, 3, 4, 5, 6]);

// Array initialization with function (w/ index). let array3: [u64; 7] = arraytools::indexedinit_with(|idx| { idx as u64 });

assert_eq!(array3, [0, 1, 2, 3, 4, 5, 6]);

// Array by-value iterator.

[derive(Debug, PartialEq, Eq)]

struct NonCopyable(u64);

let array4: [NonCopyable; 7] = arraytools::indexedinit_with(|idx| NonCopyable(idx as u64));

let iter = ArrayIntoIterator::new(array4);

let array5: [NonCopyable; 7] = arraytools::tryinitfromiterator(iter).unwrap();

assert_eq!(array5, [ NonCopyable(0), NonCopyable(1), NonCopyable(2), NonCopyable(3), NonCopyable(4), NonCopyable(5), NonCopyable(6), ]); ```