oom - One Or Many slice types

Build Status Documentation Crates.io

Took inspirations from the "Parse, don’t validate" article.

This package defines two types: NonEmptySlice and NonEmptyMutSlice. Note that those types are borrow types (not owned type). So you cannot use them without borrow contents from array, slice or Vec. Those types don't implement trait Deref or DerefMut, it is intentional to avoid confusion when resolving methods. If you want &[T], consider using as_slice or as_mut_slice.

Perhaps maybe in the future we will have NonEmptyVec, but there are design questions about semantics when vec.pop().

The size of NonEmptySlice and NonEmptyMutSlice are the same as &[T].

The differences from &[T]: * .len() returns std's NonZeroUsize. * .is_empty() is always false. * These methods don't return None: - first - first_mut - last - last_mut - split_first - split_last - split_first_mut - split_last_mut

Notable features

Supported Rust versions

Latest stable. Although I don't use new really new shiny features, but I don't build on older Rust stable versions so you should test it yourself.

Usage

Add this to your Cargo.toml:

toml [dependencies] oom = "0.0.1"

Or assuming you installed cargo-edit, use:

cargo add oom

Thanks for inspirations from

License

All the code in this repository is released under the MIT License, for more information read the COPYRIGHT file.