Crate halfling

source ·
Expand description

Basic utilities and structures for handling nibbles.

§Nibbles

A nibble (sometimes also nybble or nybl) is a 4-bit unit of data, equivalent in size to a single-digit hexadecimal number. Historically, nibbles were used in early computers to represent small enumerations, e.g. the individual digits of a base-10 number, but today they are largely API details (as opposed to genuinely necessary memory-saving constructs).

halfling’s Nibble is a byte-width struct containing a single nibble, which enables the niche value optimization (a Nibble has 4 unused bits, and hence 240 such niches are available). They are byte-width due to Rust’s fundamental expectation that all types are at least byte-aligned, which prevents us from constructing a single type that genuinely consumes only a nibble of memory.

Structs§