diff --git a/fifteen_min/src/find_amenities.rs b/fifteen_min/src/find_amenities.rs index 0092d72e40..ee9c2a96fa 100644 --- a/fifteen_min/src/find_amenities.rs +++ b/fifteen_min/src/find_amenities.rs @@ -23,7 +23,7 @@ impl FindAmenity { .map(|at| Choice::new(at.to_string(), at)) .collect(), Box::new(move |at, ctx, app| { - let multi_isochrone = create_multi_isochrone(ctx, app, at, options.clone()); + let multi_isochrone = create_multi_isochrone(ctx, app, at, options); return Transition::Replace(Results::new_state(ctx, app, multi_isochrone, at)); }), ) diff --git a/game/src/edit/mod.rs b/game/src/edit/mod.rs index 476ae44b95..ab5f449269 100644 --- a/game/src/edit/mod.rs +++ b/game/src/edit/mod.rs @@ -220,11 +220,7 @@ impl State for EditMode { "open a saved proposal" => { if app.primary.map.unsaved_edits() { Transition::Multi(vec![ - Transition::Replace(LoadEdits::new_state( - ctx, - app, - mode.clone(), - )), + Transition::Replace(LoadEdits::new_state(ctx, app, mode)), Transition::Push(SaveEdits::new_state( ctx, app, @@ -238,11 +234,7 @@ impl State for EditMode { )), ]) } else { - Transition::Replace(LoadEdits::new_state( - ctx, - app, - mode.clone(), - )) + Transition::Replace(LoadEdits::new_state(ctx, app, mode)) } } "create a blank proposal" => { diff --git a/game/src/edit/traffic_signals/edits.rs b/game/src/edit/traffic_signals/edits.rs index 628cb91550..c978d4dd02 100644 --- a/game/src/edit/traffic_signals/edits.rs +++ b/game/src/edit/traffic_signals/edits.rs @@ -287,7 +287,7 @@ pub fn edit_entire_signal( apply_map_edits(ctx, app, edits); Transition::Multi(vec![ Transition::Pop, - Transition::Replace(StopSignEditor::new_state(ctx, app, i, mode.clone())), + Transition::Replace(StopSignEditor::new_state(ctx, app, i, mode)), ]) } x if x == close => { diff --git a/game/src/edit/traffic_signals/preview.rs b/game/src/edit/traffic_signals/preview.rs index f9acf7b45b..602141a5f6 100644 --- a/game/src/edit/traffic_signals/preview.rs +++ b/game/src/edit/traffic_signals/preview.rs @@ -88,10 +88,10 @@ pub fn make_previewer( Choice::strings(vec![random, right_now]), Box::new(move |x, ctx, app| { if x == "random agents around these intersections" { - for (idx, i) in members.iter().enumerate() { + for (idx, i) in members.into_iter().enumerate() { if idx == 0 { // Start at the current stage - let signal = app.primary.map.get_traffic_signal(*i); + let signal = app.primary.map.get_traffic_signal(i); // TODO Use the offset correctly // TODO If there are variable stages, this could land anywhere let mut step = Duration::ZERO; @@ -106,7 +106,7 @@ pub fn make_previewer( ); } - spawn_agents_around(*i, app); + spawn_agents_around(i, app); } } else { app.primary.sim = app.primary.suspended_sim.as_ref().unwrap().clone(); diff --git a/map_gui/src/tools/ui.rs b/map_gui/src/tools/ui.rs index b5f4f93e7f..0c7b0806ee 100644 --- a/map_gui/src/tools/ui.rs +++ b/map_gui/src/tools/ui.rs @@ -11,7 +11,8 @@ use crate::AppLike; /// Choose something from a menu, then feed the answer to a callback. pub struct ChooseSomething { panel: Panel, - cb: Box Transition>, + // Wrapped in an Option so that we can consume it once + cb: Option Transition>>, } impl ChooseSomething { @@ -19,7 +20,7 @@ impl ChooseSomething { ctx: &mut EventCtx, query: I, choices: Vec>, - cb: Box Transition>, + cb: Box Transition>, ) -> Box> { Box::new(ChooseSomething { panel: Panel::new_builder(Widget::col(vec![ @@ -30,7 +31,7 @@ impl ChooseSomething { Menu::widget(ctx, choices).named("menu"), ])) .build(ctx), - cb, + cb: Some(cb), }) } } @@ -42,7 +43,9 @@ impl State for ChooseSomething { "close" => Transition::Pop, _ => { let data = self.panel.take_menu_choice::("menu"); - (self.cb)(data, ctx, app) + // If the callback doesn't replace or pop this ChooseSomething state, then + // it'll break when the user tries to interact with the menu again. + (self.cb.take().unwrap())(data, ctx, app) } }, _ => {