nook

Crates.ionook
lib.rsnook
version0.1.0
sourcesrc
created_at2022-11-26 12:46:52.347163
updated_at2022-11-26 12:46:52.347163
descriptionUseful types with niches
homepage
repositoryhttps://github.com/tialaramex/nook/
max_upload_size
id723242
size7,541
(tialaramex)

documentation

README

Nook

Nook will become a collection of Rust types with niches

Niches

Rust types can have a "niche" which will be used during type layout to make containing types smaller than they'd otherwise need to be. For example&T is the same size as Option<&T>.

The Rust standard library includes std::num::NonZeroIsize and similar non-zero types with this property. Today we cannot add niches to our own types without nightly Rust features, and so that's what this crate does. But since the existence of niches is crucial to Rust's design, some day they'll be stabilized:

joshtriplett's Proposed RFC is the current effort towards stabilisation.

The intent is that Nook will grow to include other types which have two desirable properties: They make sense as types, and yet they also offer a niche

Types so far

nook::BalancedI8 nook::BalancedI16 nook::BalancedI32 nook::BalancedI64

Balanced integers are a pleasant and in some ways easier to use integral type lacking the most negative value from ordinary signed integers

Commit count: 3

cargo fmt