nonempty-collections
Correct-by-construction non-empty collections.
1.4.0
8.5M downloads/mo
#3410 most downloaded on crates.io
fosskers/nonempty-collections
What this package is like to depend on
Last release 26 days ago
28 Jul 2026
Release timing varies
gaps range from 2 weeks to 7 months
Nearly every release is documented
notes for 20 of 22 stable releases
3 versions withdrawn
withdrawn after publishing
3 years old
25 releases · first in 2023
6 releases in the last 12 months
see the full history below
Release timeline
25 releases · Apr 2023 to Jul 2026Releases
latest 25-
1.4.028 Jul 2026Release notes
Open source →Added
- vector:
NEVec::reverse, mysteriously missing until this point. - vector: Support for
rand::seq::SliceRandom, exposing ashufflefunction forNEVec. - set:
NEBTreeSetand its macronebts!. - map:
NEBTreeMapand its macronebtm!. - index:
NEIndexSetand its macroneis!.
Changed
- index: The
ne_indexmapmacro has a shorter aliasneimand the original has
been hidden from the docs.
Release notes
Open source →Added
- vector:
NEVec::reverse, mysteriously missing until this point. - vector: Support for
rand::seq::SliceRandom, exposing ashufflefunction forNEVec. - set:
NEBTreeSetand its macronebts!. - map:
NEBTreeMapand its macronebtm!. - index:
NEIndexSetand its macrone_indexset.
Changed
- index: The
ne_indexmapmacro has a shorter aliasneimand the original has been hidden from the docs.
- vector:
-
1.3.013 Jan 2026Release notes
Open source →Added
- vector:
NEVec::from_elemexposed for times when you wantnev![foo; n]butnis notconst. - slice:
NESlice::lastto matchNEVec.
Changed
- vector: The
Indeximpl has been generalized to accept more slice patterns.
Release notes
Open source →Added
- vector:
NEVec::from_elemexposed for times when you wantnev![foo; n]butnis notconst. - slice:
NESlice::lastto matchNEVec.
Changed
- vector: The
Indeximpl has been generalized to accept more slice patterns.
- vector:
-
1.2.111 Nov 2025Release notes
Open source →Happy Remembrance Day.
Added
NonEmptyIterator::intersperse, finally!Iterator::interspersewithinstd
is still not stabilized after years of waiting, and its annoying to depend on
itertoolsjust for this.- More impls of
FromNonEmptyIterator. You can now fold non-empty iterators
intoString,BTreeMap,BTreeSet,PathBuf, and().
Release notes
Open source →Happy Remembrance Day.
Added
NonEmptyIterator::intersperse, finally!Iterator::interspersewithinstdis still not stabilized after years of waiting, and its annoying to depend onitertoolsjust for this.- More impls of
FromNonEmptyIterator. You can now fold non-empty iterators intoString,BTreeMap,BTreeSet,PathBuf, and().
-
1.2.011 Nov 2025Nothing published for this version
-
1.1.015 Oct 2025Release notes
Open source →Added
- The
Singletontrait. NonEmptyIterator::unzip.Extendimpls forNESet,NEMap, andNEIndexMap.
Release notes
Open source →Added
- The
Singletontrait. NonEmptyIterator::unzip.Extendimpls forNESet,NEMap, andNEIndexMap.
- The
-
1.0.106 Sep 2025Release notes
Open source →Added
- Various
AsRefimpls.
Fixed
- Overly restrictive bounds on the
PartialEqimpl forNEMap.
Release notes
Open source →Added
- Various
AsRefimpls.
Fixed
- Overly restrictive bounds on the
PartialEqimpl forNEMap.
- Various
-
1.0.030 Jun 2025Release notes
Open source →Five months since the big changes and no major issues. If there are, we can now
fix them in the normal Semver way.Added
nev![a; n]syntax (similar tovec![a; n])
Changed
- Bumped the Rust Edition to 2024.
Release notes
Open source →Five months since the big changes and no major issues. If there are, we can now fix them in the normal Semver way.
Added
nev![a; n]syntax (similar tovec![a; n])
Changed
- Bumped the Rust Edition to 2024.
-
0.3.114 Jun 2025Release notes
Open source →Added
iter_mut()toNEVec,NEMap, andNEIndexMappeekable()toNonEmptyIteratorremove(),swap_remove(),retain(), andretain_mut()toNEVec.AsRef<[T]>forNESlice.
Release notes
Open source →Added
iter_mut()toNEVec,NEMap, andNEIndexMappeekable()toNonEmptyIteratorremove(),swap_remove(),retain(), andretain_mut()toNEVec.AsRef<[T]>forNESlice.
-
0.3.015 Feb 2025Release notes
Open source →Huge thanks to Rinde van Lon for implementing the bulk of these new changes and additions. Thanks to him, the various non-empty collections now have much better performance characteristics.
Changed
- BREAKING: Redesign of
NonEmptyIterator:NonEmptyIteratoris now bounded byIntoIteratorand has default
implementations of all methods (i.e. it is a marker trait).NonEmptyIterator::first()is renamed tonext()and the old implementation ofnext()is removed.NonEmptyIterator::all()now consumes selfNonEmptyIterator::any()now consumes selfNonEmptyIterator::nth()now consumes selfNonEmptyIterator::take(usize)->NonEmptyIterator::take(NonZeroUsize)and doesn't panic anymore
- BREAKING:
NEVec::truncate(usize)->NEVec::truncate(NonZeroUsize)and doesn't panic anymore - BREAKING: Capacities for all collections now use
NonZeroUsizeinstead ofusize:with_capacity(NonZeroUsize)with_capacity_and_hasher(NonZeroUsize)capacity() -> NonZeroUsize
- BREAKING: All fields are now private for
NEVec,NEMap,NESet, andNESlice - BREAKING: Removed:
NESlice::new(&T, &[T])IntoIteratorProxy
- BREAKING: Methods that are no longer
const:NEVec::new()NEVec::first()
- BREAKING: non-empty maps and sets now behave similarly to their possibly
empty counter parts: when created from an iterator with duplicates, the last
occurence is kept. - BREAKING: Consistent API, new naming to align with Rust's naming
conventions and indicate the fallibility of the function:from_vectotry_from_vecfrom_maptotry_from_mapfrom_slicetotry_from_slicefrom_settotry_from_set.
- BREAKING:
IteratorExtis removed in favor ofIntoIteratorExt. Now it's
possible to calltry_into_nonempty_iter()instead ofto_nonempty_iter()on
all regular iterators because regular iterators also implementIntoIterator. - BREAKING:
.iter(),.iter_mut(), etc, are now prefixed withnonempty_ FromNonEmptyIterator<T>is now implemented forHashSet<T, S>instead of
HashSet<T>(with the default hasher).
Fixed
- Fixes bug in
PartialEq for NEIndexMap, previously, maps with unequal lengths
would be considered equal if the shorter map would contain the same values as
the longer map. - Fixes bug in
NEMap::with_capacity()andNESet::with_capacity(), it wasn't
possible to call this method without explicitly specifying the type forS
(the hasher). For this method it is assumed that it always uses the default
hasher (just like instd), in case the user wants to specify the hasher
with_capacity_and_hasher()can be used. The fix moved the method into the
properimplblock.
Added
- New feature
either: addsNEEitheran extension toeither::Either. - New feature
itertools: adds a newNonEmptyItertoolstrait that is an
extension of theNonEmptyIteratorsimilar to howItertoolsextends
Iterator. So far,cartesian_product(),sorted_by_key(), and
all_unique()are implemented. NonEmptyIterator::find()the equivalent ofIterator::find().IntoNonEmptyIterator for &NEVec,&NEIndexMap,&NEMap,&NESet,
&NESlice,&[T; $i] where $i > 0(these previously only existed for their
owned equivalents)NESlice::from_slice()is nowconstIndex<usize> for NESlice- All public types now implement
Debug - Aliases
ne_vecfornev,ne_hashsetfornes, andne_hashmapfornem. - Strict lint configuration
- The rust version to which the library is build is now pinned, to avoid accidental breakage.
- A
justfilethat allows to run
pre-configured commands to check the codebase. E.g.just lintorjust test. - Benchmarks for
VecversusNEVec. - Added
.iter()methods to all collections returning a regularIterator.
Release notes
Open source →Changed
- BREAKING: Redesign of
NonEmptyIterator:NonEmptyIteratoris now bounded byIntoIteratorand has default implementations of all methods (i.e. it is a marker trait).NonEmptyIterator::first()is renamed tonext()and the old implementation ofnext()is removed.NonEmptyIterator::all()now consumes selfNonEmptyIterator::any()now consumes selfNonEmptyIterator::nth()now consumes selfNonEmptyIterator::take(usize)->NonEmptyIterator::take(NonZeroUsize)and doesn't panic anymore
- BREAKING:
NEVec::truncate(usize)->NEVec::truncate(NonZeroUsize)and doesn't panic anymore - BREAKING: Capacities for all collections now use
NonZeroUsizeinstead ofusize:with_capacity(NonZeroUsize)with_capacity_and_hasher(NonZeroUsize)capacity() -> NonZeroUsize
- BREAKING: All fields are now private for
NEVec,NEMap,NESet, andNESlice - BREAKING: Removed:
NESlice::new(&T, &[T])IntoIteratorProxy
- BREAKING: Methods that are no longer
const:NEVec::new()NEVec::first()
- BREAKING: non-empty maps and sets now behave similarly to their possibly empty counter parts: when created from an iterator with duplicates, the last occurence is kept.
- BREAKING: Consistent API, new naming to align with Rust's naming
conventions and indicate the fallibility of the function:
from_vectotry_from_vecfrom_maptotry_from_mapfrom_slicetotry_from_slicefrom_settotry_from_set.
- BREAKING:
IteratorExtis removed in favor ofIntoIteratorExt. Now it's possible to calltry_into_nonempty_iter()instead ofto_nonempty_iter()on all regular iterators because regular iterators also implementIntoIterator. - BREAKING:
.iter(),.iter_mut(), etc, are now prefixed withnonempty_ FromNonEmptyIterator<T>is now implemented forHashSet<T, S>instead ofHashSet<T>(with the default hasher).
Fixed
- Fixes bug in
PartialEq for NEIndexMap, previously, maps with unequal lengths would be considered equal if the shorter map would contain the same values as the longer map. - Fixes bug in
NEMap::with_capacity()andNESet::with_capacity(), it wasn't possible to call this method without explicitly specifying the type forS(the hasher). For this method it is assumed that it always uses the default hasher (just like instd), in case the user wants to specify the hasherwith_capacity_and_hasher()can be used. The fix moved the method into the properimplblock.
Added
- New feature
either: addsNEEitheran extension toeither::Either. - New feature
itertools: adds a newNonEmptyItertoolstrait that is an extension of theNonEmptyIteratorsimilar to howItertoolsextendsIterator. So far,cartesian_product(),sorted_by_key(), andall_unique()are implemented. NonEmptyIterator::find()the equivalent ofIterator::find().IntoNonEmptyIterator for &NEVec,&NEIndexMap,&NEMap,&NESet,&NESlice,&[T; $i] where $i > 0(these previously only existed for their owned equivalents)NESlice::from_slice()is nowconstIndex<usize> for NESlice- All public types now implement
Debug - Aliases
ne_vecfornev,ne_hashsetfornes, andne_hashmapfornem. - Strict lint configuration
- The rust version to which the library is build is now pinned, to avoid accidental breakage.
- A
justfilethat allows to run pre-configured commands to check the codebase. E.g.just lintorjust test. - Benchmarks for
VecversusNEVec. - Added
.iter()methods to all collections returning a regularIterator.
- BREAKING: Redesign of
-
0.2.926 Aug 2024Release notes
Open source →Added
NonEmptyIterator::group_by.NVec::sort_byandNEVec::sort_by_key.- An impl of
ExtendforNEVec.
Fixed
NEVec::sortavoids a second internalsort.
Release notes
Open source →Added
NonEmptyIterator::group_by.NVec::sort_byandNEVec::sort_by_key.- An impl of
ExtendforNEVec.
Fixed
NEVec::sortavoids a second internalsort.
-
0.2.819 Aug 2024 -
0.2.722 Jul 2024 -
0.2.626 Jun 2024 -
0.2.509 Apr 2024 -
0.2.403 Apr 2024Release notes
Open source →Added
- Added
NEVec::partition_pointto match the function of the same name instd.
Fixed
- Render feature-gated types on
docs.rs.
- Added
-
0.2.319 Mar 2024 -
0.2.218 Mar 2024 withdrawnRelease notes
Open source →Fixed
IntoIteratorforNEChunksyielding the wrong type.NonEmptyIteratorforNEChunksmissing a cutoff condition.
-
0.2.115 Mar 2024 withdrawnRelease notes
Open source →Added
- The missing
IntoIteratorimpl forNEChunks. IntoIteratorExtfor direct conversion from anything that implementsIntoIterator. Thanks to Rinde van Lon.
Fixed
- A bug involving repeated keys in
NEMapandNEIndexedMap. Thanks to Rinde van Lon.
- The missing
-
0.2.014 Mar 2024 withdrawnRelease notes
Open source →Added
NEIndexMap, thanks to Rinde van Lon.NonEmptyIterator::max_by_keyandNonEmptyIterator::min_by_key, also thanks to Rinde.NEVec::with_capacityNEVec::nonempty_chunksandNESlice::nonempty_chunks
Changed
- BREAKING: All
lenimplementations andNonEmptyIterator::counthave had their return type changed toNonZeroUsize.
-
0.1.512 Jan 2024Release notes
Open source →Added
NonEmptyIterator::reduce, which yields a concreteSelf::Iteminstead of anOption.IteratorExt::to_nonempty_iterfor converting any givenIteratorinto a non-empty one (if possible).- The
NEVec::dedup*series for removing duplicate items in-place.
Fixed
- Account for potentially duplicated
headvalue when converting into anNESetfrom other nonempty iterators.
-
0.1.402 Nov 2023Release notes
Open source →Added
FromNonEmptyIteratorimpls forNEMapandNESet.Debug,Clone,PartialEq, andEqforNEMap.
-
0.1.315 Sep 2023Release notes
Open source →Added
NESlicefor when what you have on hand is already borrowed. Thanks again to Greg Shuflin.
-
0.1.205 Sep 2023Release notes
Open source →Added
- A
FromNonEmptyIteratorinstance forResult, meaning you cancollectinto a guaranteedResult<NEVec<...>, Error>(or other nonempty type). Thanks to Greg Shuflin.
- A
-
0.1.108 Apr 2023Release notes
Open source →Added
- Missing
IntoNonEmptyIteratorinstances. - Missing
Intoiteratorinstance forFlatMap.
Fixed
- Incorrect
IntoIteratorforTake.
- Missing
-
0.1.007 Apr 2023Nothing published for this version