https://github.com/cloudhead/nonempty
Correct by construction non-empty list
https://github.com/cloudhead/nonempty
Last synced: 11 months ago
JSON representation
Correct by construction non-empty list
- Host: GitHub
- URL: https://github.com/cloudhead/nonempty
- Owner: cloudhead
- License: mit
- Created: 2019-11-07T16:49:03.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-01-13T09:52:09.000Z (about 1 year ago)
- Last Synced: 2025-04-01T01:37:54.664Z (12 months ago)
- Language: Rust
- Homepage:
- Size: 78.1 KB
- Stars: 61
- Watchers: 3
- Forks: 24
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Correct by Construction Non-Empty List
This package exposes a type `NonEmpty` with a data representation
that guarantees non-emptiness statically:
struct NonEmpty(T, Vec)
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 = l.into();
assert_eq!(v, vec![42, 36, 58]);