#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

#1827 in Data structures

Download history 188/week @ 2024-06-17 277/week @ 2024-06-24 54/week @ 2024-07-01 216/week @ 2024-07-08 339/week @ 2024-07-15 403/week @ 2024-07-22 202/week @ 2024-07-29 189/week @ 2024-08-05 154/week @ 2024-08-12 160/week @ 2024-08-19 141/week @ 2024-08-26 290/week @ 2024-09-02 197/week @ 2024-09-09 121/week @ 2024-09-16 190/week @ 2024-09-23 152/week @ 2024-09-30

684 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