9 releases
0.3.0 | Apr 21, 2024 |
---|---|
0.2.1 | Feb 4, 2024 |
0.2.0 | Jan 17, 2024 |
0.1.5 | Jan 6, 2024 |
0.1.4 | Dec 28, 2023 |
#673 in Encoding
216 downloads per month
20KB
426 lines
Halfling
A library of basic utilities for working with nibbles.
Typical usage of this crate would be to reexport the principal type as part of a public API, though we encourage wrapping in newtypes while halfling
is still pre-v1.0.0; in particular the delegate crate is useful for this purpose.
lib.rs
:
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.
Dependencies
~335–800KB
~19K SLoC