Crates.io | no_vec |
lib.rs | no_vec |
version | 0.3.0 |
source | src |
created_at | 2018-07-06 18:59:15.686836 |
updated_at | 2019-11-16 10:29:21.293092 |
description | A library for modifying sized arrays |
homepage | https://github.com/DenisKolodin/no_vec |
repository | https://github.com/DenisKolodin/no_vec |
max_upload_size | |
id | 73142 |
size | 6,590 |
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]);