(mode_v: &'a mut ModeEntry, name: &str)
| 52 | } |
| 53 | |
| 54 | pub fn ensure_model<'a>(mode_v: &'a mut ModeEntry, name: &str) -> &'a mut ModelEntry { |
| 55 | if let Some(i) = mode_v.models.iter().position(|m| m.name == name) { |
| 56 | return &mut mode_v.models[i]; |
| 57 | } |
| 58 | mode_v.models.push(ModelEntry { |
| 59 | name: name.to_string(), |
| 60 | route_api_model: None, |
| 61 | tasks: Default::default(), |
| 62 | }); |
| 63 | mode_v.models.last_mut().unwrap() |
| 64 | } |
| 65 | |
| 66 | /// Normalize mode aliases to their canonical names before saving. |
| 67 | pub fn canonical_mode(mode: &str) -> &str { |