vec_to_array
Moves a heap allocated Vec
into a stack allocated array. In most cases you will want to prefer using try_into
(https://doc.rust-lang.org/alloc/vec/struct.Vec.html#impl-TryFrom%3CVec%3CT,+A%3E%3E-for-%5BT;+N%5D)
unless you need the array on stack for some reason.
let vec: = vec!;
let array: = vec_to_array!;
assert_eq!;
let vec: = vec!;
let array: = try_vec_to_array!;
assert_eq!;
Motivation
For Vec
, Into
is not implement for arrays greater than a size of 12.
let v: = vec!;
let arr: = v.into; /// will not compile
let v: = vec!;
let arr: = v.try_into; /// Will work but is on the heap
Solution this crate adds vec_to_array!
and try_vec_to_array!