no_vec

Crates.iono_vec
lib.rsno_vec
version0.3.0
sourcesrc
created_at2018-07-06 18:59:15.686836
updated_at2019-11-16 10:29:21.293092
descriptionA library for modifying sized arrays
homepagehttps://github.com/DenisKolodin/no_vec
repositoryhttps://github.com/DenisKolodin/no_vec
max_upload_size
id73142
size6,590
Denis Kolodin (therustmonk)

documentation

https://docs.rs/no_vec/

README

[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]);
Commit count: 15

cargo fmt