PackageTrack
Sign in Get early access

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 2026
2024 2025 2026
Release Pre-release Withdrawn

Releases

latest 25
  1. 1.4.0 28 Jul 2026
    Release notes

    Added

    • vector: NEVec::reverse, mysteriously missing until this point.
    • vector: Support for rand::seq::SliceRandom, exposing a shuffle function for NEVec.
    • set: NEBTreeSet and its macro nebts!.
    • map: NEBTreeMap and its macro nebtm!.
    • index: NEIndexSet and its macro neis!.

    Changed

    • index: The ne_indexmap macro has a shorter alias neim and the original has
      been hidden from the docs.
    Open source →
    Release notes

    Added

    • vector: NEVec::reverse, mysteriously missing until this point.
    • vector: Support for rand::seq::SliceRandom, exposing a shuffle function for NEVec.
    • set: NEBTreeSet and its macro nebts!.
    • map: NEBTreeMap and its macro nebtm!.
    • index: NEIndexSet and its macro ne_indexset.

    Changed

    • index: The ne_indexmap macro has a shorter alias neim and the original has been hidden from the docs.
    Open source →
  2. 1.3.0 13 Jan 2026
    Release notes

    Added

    • vector: NEVec::from_elem exposed for times when you want nev![foo; n] but n is not const.
    • slice: NESlice::last to match NEVec.

    Changed

    • vector: The Index impl has been generalized to accept more slice patterns.
    Open source →
    Release notes

    Added

    • vector: NEVec::from_elem exposed for times when you want nev![foo; n] but n is not const.
    • slice: NESlice::last to match NEVec.

    Changed

    • vector: The Index impl has been generalized to accept more slice patterns.
    Open source →
  3. 1.2.1 11 Nov 2025
    Release notes

    Happy Remembrance Day.

    Added

    • NonEmptyIterator::intersperse, finally! Iterator::intersperse within std
      is still not stabilized after years of waiting, and its annoying to depend on
      itertools just for this.
    • More impls of FromNonEmptyIterator. You can now fold non-empty iterators
      into String, BTreeMap, BTreeSet, PathBuf, and ().
    Open source →
    Release notes

    Happy Remembrance Day.

    Added

    • NonEmptyIterator::intersperse, finally! Iterator::intersperse within std is still not stabilized after years of waiting, and its annoying to depend on itertools just for this.
    • More impls of FromNonEmptyIterator. You can now fold non-empty iterators into String, BTreeMap, BTreeSet, PathBuf, and ().
    Open source →
  4. 1.2.0 11 Nov 2025

    Nothing published for this version

  5. 1.1.0 15 Oct 2025
    Release notes

    Added

    • The Singleton trait.
    • NonEmptyIterator::unzip.
    • Extend impls for NESet, NEMap, and NEIndexMap.
    Open source →
    Release notes

    Added

    • The Singleton trait.
    • NonEmptyIterator::unzip.
    • Extend impls for NESet, NEMap, and NEIndexMap.
    Open source →
  6. 1.0.1 06 Sep 2025
    Release notes

    Added

    • Various AsRef impls.

    Fixed

    • Overly restrictive bounds on the PartialEq impl for NEMap.
    Open source →
    Release notes

    Added

    • Various AsRef impls.

    Fixed

    • Overly restrictive bounds on the PartialEq impl for NEMap.
    Open source →
  7. 1.0.0 30 Jun 2025
    Release notes

    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 to vec![a; n])

    Changed

    • Bumped the Rust Edition to 2024.
    Open source →
    Release notes

    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 to vec![a; n])

    Changed

    • Bumped the Rust Edition to 2024.
    Open source →
  8. 0.3.1 14 Jun 2025
    Release notes

    Added

    • iter_mut() to NEVec, NEMap, and NEIndexMap
    • peekable() to NonEmptyIterator
    • remove(), swap_remove(), retain(), and retain_mut() to NEVec.
    • AsRef<[T]> for NESlice.
    Open source →
    Release notes

    Added

    • iter_mut() to NEVec, NEMap, and NEIndexMap
    • peekable() to NonEmptyIterator
    • remove(), swap_remove(), retain(), and retain_mut() to NEVec.
    • AsRef<[T]> for NESlice.
    Open source →
  9. 0.3.0 15 Feb 2025
    Release notes

    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:
      • NonEmptyIterator is now bounded by IntoIterator and has default
        implementations of all methods (i.e. it is a marker trait).
      • NonEmptyIterator::first() is renamed to next() and the old implementation of next() is removed.
      • NonEmptyIterator::all() now consumes self
      • NonEmptyIterator::any() now consumes self
      • NonEmptyIterator::nth() now consumes self
      • NonEmptyIterator::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 NonZeroUsize instead of usize:
      • with_capacity(NonZeroUsize)
      • with_capacity_and_hasher(NonZeroUsize)
      • capacity() -> NonZeroUsize
    • BREAKING: All fields are now private for NEVec, NEMap, NESet, and NESlice
    • 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_vec to try_from_vec
      • from_map to try_from_map
      • from_slice to try_from_slice
      • from_set to try_from_set.
    • BREAKING: IteratorExt is removed in favor of IntoIteratorExt. Now it's
      possible to call try_into_nonempty_iter() instead of to_nonempty_iter() on
      all regular iterators because regular iterators also implement IntoIterator.
    • BREAKING: .iter(), .iter_mut(), etc, are now prefixed with nonempty_
    • FromNonEmptyIterator<T> is now implemented for HashSet<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() and NESet::with_capacity(), it wasn't
      possible to call this method without explicitly specifying the type for S
      (the hasher). For this method it is assumed that it always uses the default
      hasher (just like in std), in case the user wants to specify the hasher
      with_capacity_and_hasher() can be used. The fix moved the method into the
      proper impl block.

    Added

    • New feature either: adds NEEither an extension to either::Either.
    • New feature itertools: adds a new NonEmptyItertools trait that is an
      extension of the NonEmptyIterator similar to how Itertools extends
      Iterator. So far, cartesian_product(), sorted_by_key(), and
      all_unique() are implemented.
    • NonEmptyIterator::find() the equivalent of Iterator::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 now const
    • Index<usize> for NESlice
    • All public types now implement Debug
    • Aliases ne_vec for nev, ne_hashset for nes, and ne_hashmap for nem.
    • Strict lint configuration
    • The rust version to which the library is build is now pinned, to avoid accidental breakage.
    • A justfile that allows to run
      pre-configured commands to check the codebase. E.g. just lint or just test.
    • Benchmarks for Vec versus NEVec.
    • Added .iter() methods to all collections returning a regular Iterator.
    Open source →
    Release notes

    Changed

    • BREAKING: Redesign of NonEmptyIterator:
      • NonEmptyIterator is now bounded by IntoIterator and has default implementations of all methods (i.e. it is a marker trait).
      • NonEmptyIterator::first() is renamed to next() and the old implementation of next() is removed.
      • NonEmptyIterator::all() now consumes self
      • NonEmptyIterator::any() now consumes self
      • NonEmptyIterator::nth() now consumes self
      • NonEmptyIterator::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 NonZeroUsize instead of usize:
      • with_capacity(NonZeroUsize)
      • with_capacity_and_hasher(NonZeroUsize)
      • capacity() -> NonZeroUsize
    • BREAKING: All fields are now private for NEVec, NEMap, NESet, and NESlice
    • 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_vec to try_from_vec
      • from_map to try_from_map
      • from_slice to try_from_slice
      • from_set to try_from_set.
    • BREAKING: IteratorExt is removed in favor of IntoIteratorExt. Now it's possible to call try_into_nonempty_iter() instead of to_nonempty_iter() on all regular iterators because regular iterators also implement IntoIterator.
    • BREAKING: .iter(), .iter_mut(), etc, are now prefixed with nonempty_
    • FromNonEmptyIterator<T> is now implemented for HashSet<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() and NESet::with_capacity(), it wasn't possible to call this method without explicitly specifying the type for S (the hasher). For this method it is assumed that it always uses the default hasher (just like in std), in case the user wants to specify the hasher with_capacity_and_hasher() can be used. The fix moved the method into the proper impl block.

    Added

    • New feature either: adds NEEither an extension to either::Either.
    • New feature itertools: adds a new NonEmptyItertools trait that is an extension of the NonEmptyIterator similar to how Itertools extends Iterator. So far, cartesian_product(), sorted_by_key(), and all_unique() are implemented.
    • NonEmptyIterator::find() the equivalent of Iterator::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 now const
    • Index<usize> for NESlice
    • All public types now implement Debug
    • Aliases ne_vec for nev, ne_hashset for nes, and ne_hashmap for nem.
    • Strict lint configuration
    • The rust version to which the library is build is now pinned, to avoid accidental breakage.
    • A justfile that allows to run pre-configured commands to check the codebase. E.g. just lint or just test.
    • Benchmarks for Vec versus NEVec.
    • Added .iter() methods to all collections returning a regular Iterator.
    Open source →
  10. 0.2.9 26 Aug 2024
    Release notes

    Added

    • NonEmptyIterator::group_by.
    • NVec::sort_by and NEVec::sort_by_key.
    • An impl of Extend for NEVec.

    Fixed

    • NEVec::sort avoids a second internal sort.
    Open source →
    Release notes

    Added

    • NonEmptyIterator::group_by.
    • NVec::sort_by and NEVec::sort_by_key.
    • An impl of Extend for NEVec.

    Fixed

    • NEVec::sort avoids a second internal sort.
    Open source →
  11. 0.2.8 19 Aug 2024
    Release notes

    Added

    • Missing FromNonEmptyIterator for HashMap.
    Open source →
  12. 0.2.7 22 Jul 2024
    Release notes

    Added

    • serde support for NEMap and NESet.
    Open source →
  13. 0.2.6 26 Jun 2024
    Release notes

    Fixed

    • Ownership issues in nem! when using non-Copy types.
    Open source →
  14. 0.2.5 09 Apr 2024
    Release notes

    Added

    • Implementation of NonEmptyIterator for fixed-sized stdlib Arrays.
    Open source →
  15. 0.2.4 03 Apr 2024
    Release notes

    Added

    • Added NEVec::partition_point to match the function of the same name in std.

    Fixed

    • Render feature-gated types on docs.rs.
    Open source →
  16. 0.2.3 19 Mar 2024
    Release notes

    Fixed

    • More edge cases involving NEChunks.
    Open source →
  17. 0.2.2 18 Mar 2024 withdrawn
    Release notes

    Fixed

    • IntoIterator for NEChunks yielding the wrong type.
    • NonEmptyIterator for NEChunks missing a cutoff condition.
    Open source →
  18. 0.2.1 15 Mar 2024 withdrawn
    Release notes

    Added

    • The missing IntoIterator impl for NEChunks.
    • IntoIteratorExt for direct conversion from anything that implements IntoIterator. Thanks to Rinde van Lon.

    Fixed

    • A bug involving repeated keys in NEMap and NEIndexedMap. Thanks to Rinde van Lon.
    Open source →
  19. 0.2.0 14 Mar 2024 withdrawn
    Release notes

    Added

    • NEIndexMap, thanks to Rinde van Lon.
    • NonEmptyIterator::max_by_key and NonEmptyIterator::min_by_key, also thanks to Rinde.
    • NEVec::with_capacity
    • NEVec::nonempty_chunks and NESlice::nonempty_chunks

    Changed

    • BREAKING: All len implementations and NonEmptyIterator::count have had their return type changed to NonZeroUsize.
    Open source →
  20. 0.1.5 12 Jan 2024
    Release notes

    Added

    • NonEmptyIterator::reduce, which yields a concrete Self::Item instead of an Option.
    • IteratorExt::to_nonempty_iter for converting any given Iterator into a non-empty one (if possible).
    • The NEVec::dedup* series for removing duplicate items in-place.

    Fixed

    • Account for potentially duplicated head value when converting into an NESet from other nonempty iterators.
    Open source →
  21. 0.1.4 02 Nov 2023
    Release notes

    Added

    • FromNonEmptyIterator impls for NEMap and NESet.
    • Debug, Clone, PartialEq, and Eq for NEMap.
    Open source →
  22. 0.1.3 15 Sep 2023
    Release notes

    Added

    • NESlice for when what you have on hand is already borrowed. Thanks again to Greg Shuflin.
    Open source →
  23. 0.1.2 05 Sep 2023
    Release notes

    Added

    • A FromNonEmptyIterator instance for Result, meaning you can collect into a guaranteed Result<NEVec<...>, Error> (or other nonempty type). Thanks to Greg Shuflin.
    Open source →
  24. 0.1.1 08 Apr 2023
    Release notes

    Added

    • Missing IntoNonEmptyIterator instances.
    • Missing Intoiterator instance for FlatMap.

    Fixed

    • Incorrect IntoIterator for Take.
    Open source →
  25. 0.1.0 07 Apr 2023

    Nothing published for this version

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive