#heavy #values #bools #boolean #regular #bool #duty

heavy_duty_bools

A library for working with heavy-duty boolean values

5 releases

0.1.4 Jan 26, 2025
0.1.3 Jan 25, 2025
0.1.2 Jan 25, 2025
0.1.1 Jan 25, 2025
0.1.0 Jan 25, 2025

#5 in #bool

Download history 121/week @ 2025-01-19 216/week @ 2025-01-26 35/week @ 2025-02-02

372 downloads per month

MIT license

9KB
120 lines

Heavy Duty Bools

Heavy Duty Bools are the more robust cousins of regular bool values in Rust. While both normal bools and Heavy Duty Bools each take up only 8 bits of memory, Heavy Duty Bools come with much stronger recoverability in the event of bit flips.

This is due to Heavy Duty Bools being u8 values where all the bits in the value are set to the same thing.

Normal Bools

True: 0b00000001

False: 0b00000000

Heavy Duty Bools

Heavy Duty True: 0b11111111

Heavy Duty False: 0b00000000

With the Heavy Duty version, if I change any bit at random, the system can still figure out which Heavy Duty value the overall value is by calling the type-associated function refresh().

On the other hand, normal bools don't have any level of inherent redundancy, as only the final bit determines the value of their entire unit.

Installation

Add this to your Cargo.toml:

[dependencies]
heavy_duty_bools = "[VERSION NUMBER]"

Add this to your crate root:

use heavy_duty_bools::*;

Support and contributions

I'm happy to receive bug reports, suggestions, questions, and other feedback. Please raise an issue or PR on GitHub or reach out on X/Twitter

No runtime deps