array-reshape
Reshaping of arrays, by value, by reference and by mutable reference, all in const fn.
<[[T; N]]>::as_flattened() and <[T]>::as_chunks() in the standard library convert to and from slices, losing the
length in the process. This crate converts between arrays of the same total length instead, for example [[T; N]; M]
into [T; N * M]:
use ;
let pairs = ;
let flat: & = pairs.flatten_ref;
assert_eq!;
let triples = pairs.;
assert_eq!;
let pairs_again = flat.;
assert_eq!;
Every conversion is also available as a free const fn (like array_reshape::flatten_ref()) that works in const
context on stable Rust. With const-trait feature, which requires nightly Rust, Flatten, Rechunk and Unflatten
become const traits, so their methods can be called in const fn directly.
Stable Rust doesn't allow computing array lengths from generic constants yet, so the length of the output is a separate
generic parameter, which is usually inferred from the context. The lengths are checked at compile time, but since the
check happens after monomorphization, it is only reported by cargo build, not cargo check.
The crate is no_std and works on stable Rust 1.85 or newer.