Crates.io | not_empty |
lib.rs | not_empty |
version | 0.1.3 |
source | src |
created_at | 2022-09-22 05:25:35.333238 |
updated_at | 2022-09-22 08:00:48.876372 |
description | Slices and vectors that are statically guaranteed to be not empty. |
homepage | |
repository | https://github.com/seancroach/not_empty |
max_upload_size | |
id | 671454 |
size | 118,132 |
Slices and vectors that are statically guaranteed to be not empty.
This crate is particularly useful for various operations on slices or vectors that would otherwise return an option now return the value with no performance penalty.
This crate is on crates.io and can be used by adding not_empty
to your dependencies in your project's Cargo.toml
:
[dependencies]
not_empty = "0.1"
View the full reference on docs.rs
here.
alloc
enables the use of allocated types through the alloc crate.serde
enables the use of the serde
crate to serialize and deserialize
any not_empty
types.std
enables the use of the standard library.Note: A compiler error is thrown if both alloc
and std
features are
enabled. Only choose up to one.
Only the std
feature is enabled by default.
There are other packages that solve this solution. When searching for my own, I primarily came across two other packages:
nonempty
which only supported vectors and didn't have a solution to
working elegantly with iterators. Also, interoperability between its exported
NonEmpty
type and other slices or vectors left much to be desired from an
architectural support. To be pedantic, I was jaded that the NonEmpty
type
was larger than a standard vector for non-zero sized types.non-empty-vec
did not enlarge the type, which was good, but it did not
meet my needs for interoperability as well.Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.