Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/therustmonk/no_vec
Rust library for arrays manipulating
https://github.com/therustmonk/no_vec
Last synced: 2 days ago
JSON representation
Rust library for arrays manipulating
- Host: GitHub
- URL: https://github.com/therustmonk/no_vec
- Owner: therustmonk
- Created: 2018-07-06T15:27:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-16T10:28:14.000Z (about 5 years ago)
- Last Synced: 2025-01-02T21:12:39.805Z (6 days ago)
- Language: Rust
- Size: 7.81 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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:
```rust
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:
```rust
let (arr, item): ([u16; 1], u16) = [123u16, 456].unstick();
assert_eq!(arr, [123]);
assert_eq!(item, 456);
```### `Vec::concrete() -> [T]`
Converts a vector to a sized array:
```rust
let arr: [u16; 2] = vec![123u16, 456].concrete();
assert_eq!(arr, [123, 456]);
```### `[T]::melt() -> Vec`
Converts a sized array to a vector:
```rust
let vec: Vec = [123u16, 456].melt();
assert_eq!(vec, vec![123, 456]);
```