vec_to_array 0.2.5

Moves a heap allocated `Vec<T>` to an stack allocated array of type `T` and size `N`.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# vec_to_array

Moves a heap allocated `Vec` into a stack allocated array.

```rust
let vec: Vec<i64> = vec![1, 2, 3];
let array: [i64; 3] = vec_to_array!(vec, i64, 3);
assert_eq!(array, [1, 2, 3]);

let vec: Vec<i32> = vec![1, 2, 3];
let array: Result<[i32; 3], VecToArrayError> = try_vec_to_array!(vec, i32, 3);
assert_eq!(array.unwrap(), [1, 2, 3]);
```

Note, 1.48.0 introduced an implementation of [try_into](https://doc.rust-lang.org/alloc/vec/struct.Vec.html#method.try_from-1) for transmuting directly on the heap, which should usually be preferred.