Richard Schneeman on Nostr: A thing I do in Ruby is to store a global list of valid options, then when provided a ...
A thing I do in Ruby is to store a global list of valid options, then when provided a value, I iterate or select one from the list. If it's not there I include the valid list in the error output.
> Invalid option "yolo", must be one of: "lol", "rofl", or "lmfao"
I want to do this with Rust, but it's less obvious how in a way that doesn't add a ton of complexity.
#rustlang
Published at
2024-11-01 17:24:27Event JSON
{
"id": "21fb952906811ae97d5da3ea1e764d1099fab3689fcc85e08de5140dc8ee506e",
"pubkey": "5c931aab4bd50aef18e4fd6a257cb53bb70fee015066bea9102ac27a8e230f5c",
"created_at": 1730481867,
"kind": 1,
"tags": [
[
"t",
"rustlang"
],
[
"proxy",
"https://ruby.social/users/Schneems/statuses/113408859681049970",
"activitypub"
]
],
"content": "A thing I do in Ruby is to store a global list of valid options, then when provided a value, I iterate or select one from the list. If it's not there I include the valid list in the error output.\n\n\u003e Invalid option \"yolo\", must be one of: \"lol\", \"rofl\", or \"lmfao\"\n\nI want to do this with Rust, but it's less obvious how in a way that doesn't add a ton of complexity.\n\n#rustlang",
"sig": "c8bf047014ef0e0e39d07bac7b22aa1a8510e4217a3c29632a608f51e66b370e7b2ac5951be79df94339abf87140bf7f5a8a637da6e18bff36859cbe353e03a4"
}