#array #slice #vec

no_vec

A library for modifying sized arrays

2 unstable releases

Uses old Rust 2015

0.3.0 Nov 16, 2019
0.1.0 Jul 6, 2018

#737 in Data structures

MIT/Apache

7KB
99 lines

[no_vec] crate

Rust crate for modifying sized arrays. It contains some useful methods:

[T; n]::stick(T) -> [T; n+1]

Adds a new element to an array:

let arr: [u16; 2] = [123u16].stick(456);
assert_eq!(arr, [123, 456]);

[T; n+1]::unstick() -> ([T; n], T)

Removes an element from an array:

let (arr, item): ([u16; 1], u16) = [123u16, 456].unstick();
assert_eq!(arr, [123]);
assert_eq!(item, 456);

Vec<T>::concrete() -> [T]

Converts a vector to a sized array:

let arr: [u16; 2] = vec![123u16, 456].concrete();
assert_eq!(arr, [123, 456]);

[T]::melt() -> Vec<T>

Converts a sized array to a vector:

let vec: Vec<u16> = [123u16, 456].melt();
assert_eq!(vec, vec![123, 456]);

No runtime deps

]