#non-empty #immutability #vec #ensure #construction #traits #pop

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

#1629 in Data structures

Download history 398/week @ 2024-07-21 220/week @ 2024-07-28 174/week @ 2024-08-04 169/week @ 2024-08-11 151/week @ 2024-08-18 133/week @ 2024-08-25 293/week @ 2024-09-01 199/week @ 2024-09-08 133/week @ 2024-09-15 179/week @ 2024-09-22 157/week @ 2024-09-29 87/week @ 2024-10-06 108/week @ 2024-10-13 137/week @ 2024-10-20 323/week @ 2024-10-27 181/week @ 2024-11-03

752 downloads per month
Used in 14 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

~165KB