From 4841a77be279d93dd7d1b3374004928e121e8c75 Mon Sep 17 00:00:00 2001 From: Avril Date: Fri, 11 Mar 2022 16:58:02 +0000 Subject: [PATCH] `space`: Added `NonZeroU8Set` (alias to `NonZeroByteSet`) and `NonZeroI8Set`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fortune for smallmap's current commit: Small curse − 小凶 --- src/space.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/space.rs b/src/space.rs index d84e03e..4b1bd18 100644 --- a/src/space.rs +++ b/src/space.rs @@ -5,7 +5,7 @@ //! * The key must be 8 bits wide and subject to the *null pointer optimisation* //! * The value must be a ZST. //! -//! This leaves pretty much only `NonZeroU8` and `NonZeroI8` as entirely space-efficient key candidates. +//! This leaves pretty much only `std::num::NonZeroU8` and `std::num::NonZeroI8` as entirely space-efficient key candidates. //! The restriction on values also means the only entirely space-efficient smallmaps are sets, enable to encode only if a key is present, with no extra information. (See `std::collections::HashSet`). use super::*; @@ -14,6 +14,16 @@ use super::*; /// This type is entirely space efficient and will only ever allocate `256` bytes of memory. pub type NonZeroByteSet = Set; +/// A set of non-zero signed 8-bit integers. +/// +/// This type is entirely space efficient and will only ever allocate `256` bytes of memory. +pub type NonZeroI8Set = Set; + +/// A set of non-zero unsigned 8-bit integers. +/// +/// This type is entirely space efficient and will only ever allocate `256` bytes of memory. +pub type NonZeroU8Set = NonZeroByteSet; + #[cfg(test)] mod tests { @@ -54,5 +64,7 @@ mod tests } size_test!(non_zero_byte_set, NonZeroByteSet, 256); + size_test!(non_zero_u8_set, NonZeroU8Set, 256); + size_test!(non_zero_i8_set, NonZeroI8Set, 256); } }