Expand description
§Hodgepodge
hodgepodge bundles ready-made enums you can drop into lessons,
prototypes, demos, and coding exercises. Each enum doubles as a small dataset
(CSS color keywords, RGB swatches, the periodic table, geography trivia, game
pieces, etc.) so you can focus on explaining a concept instead of inventing
sample data.
Bring everything into scope with use hodgepodge::*;, then iterate over the
variants (with the strum feature), format their values, or serialize them
(with the serde feature) depending on what the example calls for.
§Feature-gated helpers
strum– derives [strum_macros::EnumIter] and [strum_macros::EnumCount] for every dataset, re-exporting [IntoEnumIterator] and [EnumCount] so you can iterate over or count the variants without depending onstrumdirectly.enum-iter/enum-count– legacy compatibility feature names that now simply forward tostrum.serde– derives [serde::Serialize] and [serde::Deserialize] so the enums can be persisted in fixtures for tutorials or quick prototypes.
§Examples
§Iterate through datasets
use hodgepodge::{Element, IntoEnumIterator};
for element in Element::iter() {
let atomic_number = element as u16;
println!("{element:?} is element {atomic_number}");
}§Format CSS color hex values
use hodgepodge::CSS;
let swatch = CSS::Tomato;
println!("{swatch:?} renders as #{swatch:06x}");§Serialize and deserialize enums
use hodgepodge::Day;
let json = serde_json::to_string(&Day::Friday).expect("serialize Day");
let day: Day = serde_json::from_str(&json).expect("deserialize Day");
assert_eq!(day, Day::Friday);Re-exports§
pub use colors::*;pub use science::*;pub use geography::*;pub use time::*;pub use games::*;pub use misc::*;
Modules§
- colors
- Color palettes ranging from ROYGBIV to CSS keywords. Color datasets ranging from rainbow mnemonics (ROYGBIV) to CMYK, RGB, and curated CSS keyword lists. All enums are C-like, so their discriminants are the RGB hex codes.
- games
- Games and leisure datasets like playing card suits and ranks. Game-centric datasets such as playing card suits and ranks.
- geography
- Geographic datasets covering continents, regions, and states. Geographic datasets covering directions, continents, and civic regions.
- misc
- Miscellaneous grab-bag datasets for playful examples. Miscellaneous datasets such as medals, ordinals, and programming trivia.
- science
- Science-themed datasets such as planets and SI prefixes. Science datasets such as metric units, SI prefixes, planets, and elements.
- time
- Temporal datasets including months and weekdays. Timekeeping datasets including weekdays and months.