diff --git a/src/tooling/playground.rs b/src/tooling/playground.rs index b691b0b..7cff56a 100644 --- a/src/tooling/playground.rs +++ b/src/tooling/playground.rs @@ -86,12 +86,12 @@ impl Settings { } } + /// Sets the knob named `name`; a knob painted before the owner's knobs changed sets nothing. fn set(&mut self, name: &str, setting: Setting) { - let slot = self - .0 - .iter_mut() - .find(|(each, _)| each.as_ref() == name) - .unwrap_or_else(|| panic!("playground: no knob named {name}")); + let Some(slot) = self.0.iter_mut().find(|(each, _)| each.as_ref() == name) else { + log::error!("playground: no knob named {name} now; {setting:?} is dropped"); + return; + }; log::info!("playground: {name} is {setting:?}"); slot.1 = setting; } @@ -280,6 +280,9 @@ mod tests { assert_eq!(settings.picked("size").as_ref(), "Md"); settings.set("share", Setting::Number(0.7)); assert_eq!(settings.number("share"), 0.7); + let before = settings.clone(); + settings.set("gone", Setting::On(true)); + assert_eq!(settings, before, "a knob no longer there sets nothing"); } #[test] diff --git a/tasks/panics.md b/tasks/panics.md index ca9f373..7fc7962 100644 --- a/tasks/panics.md +++ b/tasks/panics.md @@ -57,7 +57,7 @@ Each item reads every site in its folders, fixes what the rules name, updates ca - [x] P40 i18n & a11y — `src/i18n` - [x] P41 Maps — `src/maps` - [x] P42 Misc — `src/misc` -- [ ] P43 Library Tooling — `src/tooling` +- [x] P43 Library Tooling — `src/tooling` - [ ] P44 Rendering — `src/rendering` - [ ] P45 Recount, acceptance table @@ -108,3 +108,4 @@ One line per item: what changed, what stayed and why, review rounds. - P40: no change. Kept, as AGENTS.md says: catalogs checked against each other at construction, message keys and arguments from code, Ely's locale table, the owner's switch over its own catalogs, constant date patterns. Review: 1 round. - P41: no change. Kept: finite and unique values, places and zooms in range (the map's own moves clamp and wrap), heat weights, routes of two places, builder misuse, tile sources and zooms, unique pins, ISO codes, the bundled world. Review: 1 round. - P42: Captcha, CookieBanner, Poll, QrCodeScanner and Survey take their handlers in `new`; the macOS web view shows wry's build and load failures in its box and logs failed bounds, visibility and focus calls (checked by reading, as Windows cannot build that module; CI builds it); kept state fits lists that changed: cookie switches, export formats, licenses, poll picks and votes, survey sheets, import mappings, quiz and flashcard places; a picture with no frame reads no code. Kept: lists present, a question's right answer, counts per option, unit tables, places from their own choices, Vote behind a pick. Review: 2 rounds. +- P43: a playground knob painted before the owner's knobs changed sets nothing. Kept: knobs present, unique and starting in range, the preview asking by its own names (code), fixed tables in the inspector, checker and tokens. Review: 1 round.