// ___ 0
//|_\_| 1 2A 3 dash 4
//| \| 5 2B 6
// ___ 7
// 01234567
const _ONE :u8 =0b01001000;
const _TWO :u8 =0b10010101;```
trying to use these in a 7 segment display type project, and thought that carrying them around in a u8 might be fun. There appear to be ways to do this, but I didn't understand how to actually make any of them work.
#how to convert u8 to array of bools?
26 messages · Page 1 of 1 (latest)
Either that or just reading the bit directly
basically just want add a few characters to a string and then print whatever it is
print_8_segment(n);
desired output:
(four empty lines in terminal)
print_8_segment(n);```
desired output:
|__|
| |
___```
This crate provides the Bitmap type as a convenient and efficient way of declaring and working with fixed size bitmaps in Rust.
you might want to look at this
I read the docs, and still can't figure out how to perform the conversion
it seems to only be able to convert from bitmaps to u8s, I tried a few of its methods and didn't get anywhere
pub fn from_value(data: <BitsImpl<SIZE> as Bits>::Store) -> Self
Construct a bitmap from a value of the same type as its backing store.
idk how to link functions in docs
sure, I can try
const _TWO :u8 =0b10010101;
fn main(){
//cannot satisfy `BitsImpl<_>: Bits`
let m = Bitmap::from_value(_TWO);
}```
i think it's designed to carry around a large number of bits in u8 containers so it's not sure what to do with a thing that already is a u8
use bitmaps::Bitmap;
const _TWO: u8 = 0b10010101;
fn main() {
let m = Bitmap::<8>::from_value(_TWO);
}
you have to specify the size
it will use an u8 if your size is <= 8
The type used to store the bitmap will be the minimum unsigned integer type required to fit the number of bits, from u8 to u128. If the size is 1, bool is used. If the size exceeds 128, an array of u128 will be used, sized as appropriately.
Source of the Rust file src/types.rs.
the implementation is a bit cursed
600 lines of macro invocations
wild
