HashMapBool
The new and improved way to use boolean values in your rust code, requiring heap allocation and wasting resources on conversion.
I wonder if LLVM would optimize it out of existence...
How it works
The value depends on whether or not the HashMap
contains a value. If it contains a value, it's true
, otherwise it's false
.
Due to the use of std::collections::HashMap
, std
is required.
Example usage
let a: HashMapBool = true.into;
let b: HashMapBool = false.into;
assert_eq!;
assert_eq!;
assert!;
assert!;
// into() moves the value out of the HashMapBool
// so we need to clone it to read the value without consuming it
if a.clone.into && b.into
let mut c = new;
assert!;
c.set_true.unwrap;
assert!;
assert_eq!;
assert_eq!;
let d = !c.clone; // c would be moved without clone
assert!;
assert!;
License
MIT