17 releases (10 breaking)

0.11.0 Dec 17, 2024
0.10.0 Feb 29, 2024
0.9.0 Nov 17, 2023
0.8.1 Dec 6, 2022
0.1.5 Nov 25, 2019

#44 in Rust patterns

Download history 101036/week @ 2024-12-09 88507/week @ 2024-12-16 36094/week @ 2024-12-23 46864/week @ 2024-12-30 88369/week @ 2025-01-06 112149/week @ 2025-01-13 100646/week @ 2025-01-20 103166/week @ 2025-01-27 124818/week @ 2025-02-03 135600/week @ 2025-02-10 149308/week @ 2025-02-17 144125/week @ 2025-02-24 150358/week @ 2025-03-03 147229/week @ 2025-03-10 145642/week @ 2025-03-17 141834/week @ 2025-03-24

592,327 downloads per month
Used in 335 crates (72 directly)

MIT license

44KB
690 lines

Correct by Construction Non-Empty List

This package exposes a type NonEmpty<T> with a data representation that guarantees non-emptiness statically:

struct NonEmpty<T>(T, Vec<T>)

The library is meant to have an interface similar to std::vec::Vec:

use nonempty::NonEmpty;

let mut l = NonEmpty::new(42);

assert_eq!(l.first(), &42);

l.push(36);
l.push(58);

let v: Vec<i32> = l.into();
assert_eq!(v, vec![42, 36, 58]);

Dependencies

~180KB