| Crates.io | non-non-full |
| lib.rs | non-non-full |
| version | 0.0.3 |
| created_at | 2025-05-25 21:38:41.138296+00 |
| updated_at | 2025-06-08 18:27:46.300475+00 |
| description | Vec and String wrappers that assert the containers are always non-empty (or, ahem, non-non-full) |
| homepage | |
| repository | https://github.com/SergeyKasmy/fetcher/crates/non-non-full |
| max_upload_size | |
| id | 1688711 |
| size | 19,163 |
Container types that guarantee non-emptiness.
This crate provides wrapper types around Vec and String that ensure they can never be empty.
The name "non-non-full" is a playful way of saying "not empty" (i.e., full).
NonEmptyVec<T>: A vector that always contains at least one elementNonEmptyString: A string that always contains at least one characteruse non_non_full::{NonEmptyVec, NonEmptyString};
// Creating non-empty containers
let vec = NonEmptyVec::new_one(42);
let string = NonEmptyString::new("Hello".to_string()).unwrap();
// Operations that would make the container empty are prevented
let mut vec = NonEmptyVec::new(vec![1, 2]).unwrap();
assert_eq!(vec.pop(), Some(2)); // Allowed - vec still contains [1]
assert_eq!(vec.pop(), None); // Prevented - would make vec empty
License: MPL-2.0