no_vec 0.3.0

A library for modifying sized arrays
Documentation
  • Coverage
  • 72.73%
    8 out of 11 items documented4 out of 11 items with examples
  • Size
  • Source code size: 6.21 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.09 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • therustmonk/no_vec
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • therustmonk

[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]);