Expand description
A non-empty set type that guarantees at least one element is present. NESet has an interface similar to HashSet with additional methods to enforce the invariant. Get started with:
let nes = NESet::new(42, vec![1, 2, 3]);
let singleton = NESet::singleton(42);
let r#macro = nes![1, 2, 3];NESet conforms to [Index], IntoIterator, [Deref], and many more, so operations are as HashSet-like as possible. They are also usually zero-cost.
let nes = nes![42, 1, 2, 3];
assert!(nes.contains(&42));
assert_eq!(nes.len(), 4);When the feature arbitrary is enabled, NESet implements [arbitrary::Arbitrary]
for generation of randomly populated instances.
Structsยง
- NESet
- Non-empty set type.