Skip to content

Correct by construction non-empty list

License

Notifications You must be signed in to change notification settings

cloudhead/nonempty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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]);

About

Correct by construction non-empty list

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages