From cf7216939b9dab5d29689a6188e054a963c2e37d Mon Sep 17 00:00:00 2001 From: Leonora Tindall Date: Sun, 7 Nov 2021 13:04:13 -0600 Subject: [PATCH] feat: meta update; this is 0.2.0! --- .gitignore | 1 + Cargo.lock | 5 ----- Cargo.toml | 9 +++++++-- README.md | 25 +++++++++++++++++++++++++ src/lib.rs | 13 +------------ 5 files changed, 34 insertions(+), 19 deletions(-) delete mode 100644 Cargo.lock create mode 100644 README.md diff --git a/.gitignore b/.gitignore index ea8c4bf..96ef6c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 42eeac7..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,5 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "nslice" -version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index a4cefd7..7fd62ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,15 @@ [package] name = "nslice" -version = "0.1.0" +version = "0.2.0" authors = ["Leonora Tindall "] -edition = "2018" +edition = "2021" description = "Structures for interpreting slices of variable length as arrays" license = "MIT" keywords = ["memory", "slice", "array"] categories = ["data-structures"] repository = "https://git.nora.codes/nora/nslice" + + +[features] +nightly = [] +default = ["nightly"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7f873a7 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# nslice + +Structures for interpreting slices of variable length as arrays. + +`nslice` provides `MinSlice` and `ExactSlice` for representing slices known to have +either exactly or at least some compile-time-known number of values. + +This is useful when dealing with a slice whose length you expect to be exactly +or at least some particular length; +rather than making runtime checks on each access, +you can check the length once and access values freely with no copying. + +```rust +# use nslice::MinSlice; + +let slice = &[1, 2, 3, 4, 5, 6]; +let minslice: &MinSlice<_, 3> = MinSlice::from_slice(slice).unwrap(); +assert_eq!(minslice.tail.len(), 3); +assert_eq!(minslice.head[0], 1); +assert_eq!(minslice.tail[2], 6); +``` + +## License + +This project is licensed MIT. diff --git a/src/lib.rs b/src/lib.rs index ef1b910..2491fab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,15 +1,4 @@ -//! Structures for interpreting slices of variable length as arrays. -//! -//! `nslice` provides `MinSlice` and `ExactSlice` for representing slices known to have -//! either exactly or at least some compile-time-known number of values. -//! ``` -//! use nslice::MinSlice; -//! let slice = &[1, 2, 3, 4, 5, 6]; -//! let minslice: &MinSlice<_, 3> = MinSlice::from_slice(slice).unwrap(); -//! assert_eq!(minslice.tail.len(), 3); -//! assert_eq!(minslice.head[0], 1); -//! assert_eq!(minslice.tail[2], 6); -//! ``` +#![doc=include_str!("../README.md")] use std::slice; /// A reference to a region of memory which is known to contain `N` or more elements