Crates.io | unempty |
lib.rs | unempty |
version | 0.1.0 |
source | src |
created_at | 2022-08-28 20:24:51.800391 |
updated_at | 2022-08-28 20:24:51.800391 |
description | Non-empty data structures for Rust |
homepage | https://github.com/jssblck/unempty |
repository | https://github.com/jssblck/unempty |
max_upload_size | |
id | 654049 |
size | 36,201 |
Non-empty data structures for Rust.
Other crates are more focused for a single data structure (e.g. Vec
or HashMap
).
The goal of this crate is to contain non-empty implementations for all commonly used data structures.
Of course, "all" is quite a lot. I intend to add to this as I need non-empty data structures. If you need one, PRs are extremely welcome!
Expressing constraints in the type system is powerful, and non-empty data structures are no exception.
A data structure that is impossible to be empty frees developers from needing to check for the empty case, and allows them to express an expectation in their types rather than solely at runtime or in their documentation.
This also enables some convenience features or even performance improvements.
For example, an unempty::Vec
can always fulfill a call to first
or last
, so these don't need to be Option
.
This crate is using pre-release semver for now (0.x.y
) while the API is being stabilized.
Once all commonly used methods for commonly used data structures exist, it'll be set to 1.0.0
to provide clarity on forwards compatibility.
"Commonly used" is of course subjective, but in general, this means:
Vec
, HashSet
, HashMap
, VecDequeue
from the standard library.Unstable / nightly only APIs aren't initially planned.
More esoteric APIs (for example, try_reserve
) will be implemented as needed. If you need one of these methods, please submit a PR or issue!