Non-Empty Containers
A simple set of non-empty alternatives to standard containers in Rust, including NonEmptyVec
.
Getting Started
Add this to your Cargo.toml
:
# Cargo.toml
[]
= "0.0.3"
The non-empty containers behave like their standard counterparts:
use NonEmptyVec;
let nev = new;
nev.push;
nev.pop;
nev.pop;
assert_eq!;
// Errors!
nev.pop;
Automatically Deriving Arbitrary
All non-empty containers can automatically derive Arbitrary
, so long as the contained type
also implements Arbitrary
. This is useful for property-based testing, such as with arbtest
.
# Cargo.toml
[]
= { = "0.0.2", = ["arbitrary"] }
And then you can simply add #[derive(Arbitrary)]
annotations to your types:
// pixels.rs
use Arbitrary;
;