non-non-full
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).
Features
NonEmptyVec<T>: A vector that always contains at least one elementNonEmptyString: A string that always contains at least one character- Optional serde support via the "serde" feature
Example
use ;
// Creating non-empty containers
let vec = new_one;
let string = new.unwrap;
// Operations that would make the container empty are prevented
let mut vec = new.unwrap;
assert_eq!; // Allowed - vec still contains [1]
assert_eq!; // Prevented - would make vec empty
License: MPL-2.0