Expand description
§punch-card
A library for making punched cards like this:
use punch_card::PunchCard;
#[rustfmt::skip]
println!("{}", std::str::from_utf8(&(
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..,
..=..=..=..=..=.. .. .. ..=..=..=..=..=..=.. ..=..=.. ..=..=..=..=..=..=.. ..=..=..=..=..=.. ..=..=..=..=..,
..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..=..,
.. ..=..=..=..=..=.. .. .. ..=.. ..=.. ..=.. .. .. .. .. ..=.. ..=.. ..=.. ..=..=.. .. .. .. .. .. ..=.. ..,
..=.. .. .. .. ..=..=..=.. .. .. .. .. .. ..=..=..=..=.. .. .. .. .. .. ..=.. .. ..=.. ..=..=.. .. .. .. ..,
.. ..=..=.. .. .. ..=..=.. .. .. ..=..=.. ..=.. ..=..=.. .. .. ..=..=.. ..=.. ..=..=.. .. ..=.. .. .. ..=..,
.. .. .. .. ..=..=..=..=..=..=.. .. .. ..=..=.. ..=..=..=..=.. .. .. ..=..=.. .. ..=..=.. .. ..=.. ..=.. ..,
.. .. .. .. ..=.. ..=..=..=.. ..=.. ..=..=.. ..=..=..=..=.. ..=.. ..=..=..=.. ..=.. ..=.. ..=..=..=.. .. ..,
).punch_card()).unwrap());§Why?
I saw the punch_card example in weird-exprs.rs and (inspired by
analog_literals) thought “what if that was useful?” and then created
this.
§Usage
Run .punch_card() on a card tuple to convert it
into an array of values
By default, punch-card supports the following sizes of card:
- n × 1 → array of
bool - n × 8 → array of
u8(probably the one you’ll be using the most) - n × 16 → array of
u16 - n × 32 → array of
u32 - n × 64 → array of
u64 - n × 128 → array of
u128
A card is simply a tuple of some amount of rows, where each row is a chain
of ..’s or ..=’s terminated by a .., as shown in the above example.
Note: this uses the generic_const_exprs feature, it should be safe to use though.
Traits§
- Punch
Card - Represents a value that is a punch card, formatted like this: