#non-empty #vec #non-empty-vec

non-empty-vec

NonEmpty vector implementation, ensure non-emptiness by construction

7 releases

0.2.3 Nov 16, 2021
0.2.2 Nov 10, 2021
0.2.0 Aug 30, 2021
0.1.2 Jul 23, 2020
0.1.0 Dec 15, 2019

#737 in Data structures

Download history 335/week @ 2024-12-15 64/week @ 2024-12-22 42/week @ 2024-12-29 236/week @ 2025-01-05 261/week @ 2025-01-12 430/week @ 2025-01-19 575/week @ 2025-01-26 1102/week @ 2025-02-02 425/week @ 2025-02-09 587/week @ 2025-02-16 840/week @ 2025-02-23 356/week @ 2025-03-02 682/week @ 2025-03-09 700/week @ 2025-03-16 906/week @ 2025-03-23 735/week @ 2025-03-30

3,050 downloads per month
Used in 15 crates (6 directly)

MIT license

12KB
286 lines

NonEmpty vector implementation, ensure non-emptiness by construction.

Inherits Vec's immutable methods through Deref trait, not implements DerefMut.

The differences from Vec:

  • len returns NonZeroUsize, is_empty always returns false.
  • first(_mut), last(_mut), split_first(_mut), split_last(_mut) don't return Option.
  • pop returns None if there is only one element in it.

More usages please look at the embedded unit testing.

Dependencies

~150KB