| Crates.io | hodgepodge |
| lib.rs | hodgepodge |
| version | 0.2.0 |
| created_at | 2020-08-05 20:58:11.105012+00 |
| updated_at | 2025-11-16 18:38:39.120805+00 |
| description | Lightweight dataset crate of enums for prototyping, teaching, and experimentation |
| homepage | https://github.com/cmccomb/hodgepodge |
| repository | https://github.com/cmccomb/hodgepodge |
| max_upload_size | |
| id | 273415 |
| size | 49,417 |
hodgepodge is a grab bag of ready-made enums you can drop into lessons, prototypes, demos, and coding exercises. Each enum doubles as a tiny dataset—covering CSS color keywords, RGB swatches, the periodic table, continents, SI prefixes, solar-system trivia, decks of cards, and more—so you can focus on teaching a concept instead of inventing boilerplate data.
The crate shines when you need to illustrate iteration, formatting, serialization, or pattern matching without stopping to build sample inputs.
Add hodgepodge to your Cargo.toml using the latest published version:
[dependencies]
hodgepodge = "0.2"
Enable optional helpers (such as iteration or serialization) by listing the relevant Cargo features:
[dependencies]
hodgepodge = { version = "0.2", features = ["strum", "serde"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Enable the strum feature to derive EnumIter/EnumCount for each dataset and re-export IntoEnumIterator. That makes it easy to loop through everything, such as the periodic table:
use hodgepodge::{Element, IntoEnumIterator};
fn main() {
for element in Element::iter() {
let atomic_number = element as u16;
println!("{element:?} is element {atomic_number}");
}
}
Enums such as CSS implement LowerHex, so you can turn a variant into its hexadecimal color code without extra helpers:
use hodgepodge::CSS;
fn main() {
let swatch = CSS::Tomato;
println!("{swatch:?} renders as #{swatch:06x}");
}
serdeAll enums derive serde::Serialize and serde::Deserialize when the serde feature is active, so shipping fixtures for tutorials is a one-liner:
use hodgepodge::Day;
fn main() -> Result<(), serde_json::Error> {
let json = serde_json::to_string(&Day::Saturday)?;
let day: Day = serde_json::from_str(&json)?;
assert_eq!(day, Day::Saturday);
Ok(())
}
| Feature | Default | Description |
|---|
strum | Disabled | Derives EnumIter and EnumCount for every dataset and re-exports the helper traits so you can iterate without depending on strum directly.
enum-iter, enum-count | Disabled | Legacy compatibility feature names that simply forward to strum.
serde | Disabled | Adds serde::Serialize and serde::Deserialize to every enum so they can be written to JSON, TOML, etc.
Enable any combination of these features with cargo flags:
cargo add hodgepodge --features "strum serde"
# or
cargo test --features "strum"
serde to build deterministic fixtures for integration tests.cargo fmt --all --checkcargo clippy --all-targets --all-features -- -D warnings -D clippy::pedanticcargo test --all-targetscargo test --all-targets --features "serde strum"