| Crates.io | oom |
| lib.rs | oom |
| version | 0.3.0 |
| created_at | 2020-09-02 04:41:40.259059+00 |
| updated_at | 2020-09-02 13:37:09.759412+00 |
| description | One or Many types (Haskell NonEmpty) |
| homepage | |
| repository | https://github.com/lzutao/rust-oom |
| max_upload_size | |
| id | 283766 |
| size | 30,008 |
Took inspirations from the "Parse, don’t validate" article.
This package defines three types: NonEmptySlice, NonEmptyMutSlice
and NonEmptyVec. Those types don't implement Deref or DerefMut trait,
it is intentional to avoid confusion when resolving methods.
If you want &[T], consider using as_slice or as_mut_slice methods.
NonEmptySlice and NonEmptyMutSlice:
&[T] and &mut [T].&[T]Vec.NonEmptyVec:
Vec<T>.push and pop methods, because those are fallible operations.
I had to deal with unsafe codes that I am not confident if I want to implement them.The differences from &[T] and Vec<T>:
.len() returns std's NonZeroUsize..is_empty() is always false.None:
firstfirst_mutlastlast_mutsplit_firstsplit_lastsplit_first_mutsplit_last_mut#![no_std]Latest stable. I use the new conditional flows in const fn available only in Rust v1.46.0.
Add this to your Cargo.toml:
[dependencies]
oom = "0.3.0"
Or assuming you installed cargo-edit, use:
cargo add oom
All the code in this repository is released under the MIT License, for more information read the COPYRIGHT file.