| Crates.io | nonempty |
| lib.rs | nonempty |
| version | 0.12.0 |
| created_at | 2019-11-07 16:55:55.006216+00 |
| updated_at | 2025-07-19 14:13:47.493811+00 |
| description | Correct by construction non-empty vector |
| homepage | |
| repository | https://github.com/cloudhead/nonempty |
| max_upload_size | |
| id | 179058 |
| size | 52,716 |
This package exposes a type NonEmpty<T> with a data representation
that guarantees non-emptiness statically:
struct NonEmpty<T>(T, Vec<T>)
The library is meant to have an interface similar to std::vec::Vec:
use nonempty::NonEmpty;
let mut l = NonEmpty::new(42);
assert_eq!(l.first(), &42);
l.push(36);
l.push(58);
let v: Vec<i32> = l.into();
assert_eq!(v, vec![42, 36, 58]);