diff --git a/native_app/src/gui/hud/keybinds.rs b/native_app/src/gui/hud/keybinds.rs index 2ff2a98d..9ff505f8 100644 --- a/native_app/src/gui/hud/keybinds.rs +++ b/native_app/src/gui/hud/keybinds.rs @@ -62,8 +62,8 @@ impl KeybindState { for key in &inp.keyboard.pressed { state.cur.push_unique(UnitInput::Key(key.clone())); } - for mouse in &inp.mouse.pressed { - state.cur.push_unique(UnitInput::Mouse(mouse.clone())); + for &mouse in &inp.mouse.pressed { + state.cur.push_unique(UnitInput::Mouse(mouse)); } if inp.mouse.wheel_delta > 0.0 { state.cur.push_unique(UnitInput::WheelUp); @@ -81,7 +81,7 @@ impl KeybindState { return; } - let ref mut comb = bindings.0.get_mut(&state.to_bind_to).unwrap().0; + let comb = &mut bindings.0.get_mut(&state.to_bind_to).unwrap().0; let mut cur = std::mem::take(&mut state.cur); cur.sort(); diff --git a/native_app/src/gui/hud/toolbox/building.rs b/native_app/src/gui/hud/toolbox/building.rs index 4f67a557..1d6cb7d3 100644 --- a/native_app/src/gui/hud/toolbox/building.rs +++ b/native_app/src/gui/hud/toolbox/building.rs @@ -1,18 +1,19 @@ -use common::FastMap; -use engine::{Context, TextureBuilder}; -use yakui::widgets::{Layer, List}; +use std::path::PathBuf; +use std::time::Instant; + +use yakui::widgets::List; use yakui::{ reflow, use_state, Alignment, Color, CrossAxisAlignment, Dim2, MainAxisAlignment, MainAxisSize, Pivot, TextureId, Vec2, }; -use crate::gui::item_icon_yakui; +use common::FastMap; use engine::wgpu::TextureFormat; +use engine::{Context, TextureBuilder}; use geom::{Camera, Degrees, Polygon, Vec3}; use goryak::{ - blur_bg, debug_constraints, debug_size, fixed_spacer, image_button, is_hovered, mincolumn, - minrow, on_secondary_container, padxy, pady, primary, secondary_container, textc, titlec, - HorizScroll, HorizScrollSize, + blur_bg, fixed_spacer, image_button, is_hovered, mincolumn, minrow, on_secondary_container, + padxy, primary, secondary_container, textc, titlec, HorizScrollSize, }; use prototypes::{ prototypes_iter, BuildingPrototypeID, GoodsCompanyID, GoodsCompanyPrototype, Prototype, @@ -20,9 +21,8 @@ use prototypes::{ }; use simulation::map::{BuildingKind, Zone}; use simulation::world_command::WorldCommand; -use std::path::PathBuf; -use std::time::Instant; +use crate::gui::item_icon_yakui; use crate::gui::specialbuilding::{SpecialBuildKind, SpecialBuildingResource}; use crate::uiworld::UiWorld; diff --git a/simulation/src/map/objects/intersection.rs b/simulation/src/map/objects/intersection.rs index f3f1af0b..54a2a923 100644 --- a/simulation/src/map/objects/intersection.rs +++ b/simulation/src/map/objects/intersection.rs @@ -156,7 +156,7 @@ impl Intersection { let (r1, r2) = (&roads[r1_id], &roads[r2_id]); let (dir1, dir2) = (r1.dir_from(id), r2.dir_from(id)); - let min_dist = if dir1.angle(dir2).abs() < 0.174532925 { + let min_dist = if dir1.angle(dir2).abs() < 0.17453292 { self.interface_calc_numerically(r1.width, r2.width, r1, r2) } else { Self::interface_calc_formula(r1.width, r2.width, dir1, dir2) @@ -193,10 +193,10 @@ impl Intersection { .points_dirs_along((1..r2.points().length() as i32).map(|d| d as f32)) .collect(); - if !(r1.src == self.id) { + if r1.src != self.id { points1.reverse(); } - if !(r2.src == self.id) { + if r2.src != self.id { points2.reverse(); } @@ -205,7 +205,7 @@ impl Intersection { .zip(points2) .map(|((p1, _), (p2, _))| (p1.xy(), p2.xy())) .find(|p| p.0.distance(p.1) > w) - .and_then(|p| Some((self.pos.xy().distance(p.0) + self.pos.xy().distance(p.0)) * 0.5)) + .map(|p| (self.pos.xy().distance(p.0) + self.pos.xy().distance(p.0)) * 0.5) .unwrap_or(50.0) } diff --git a/simulation/src/transportation/train.rs b/simulation/src/transportation/train.rs index ba6f8bd9..151abce2 100644 --- a/simulation/src/transportation/train.rs +++ b/simulation/src/transportation/train.rs @@ -55,7 +55,7 @@ pub struct RailWagon { pub rolling_stock: RollingStockID, } -pub fn calculate_locomotive(wagons: &Vec) -> Locomotive { +pub fn calculate_locomotive(wagons: &[RollingStockID]) -> Locomotive { let info = wagons.iter().fold( (720.0, 0.0, 0.0, 0.0, 0), |(speed, acc, dec, length, mass): (f32, f32, f32, f32, u32), &id| { @@ -78,7 +78,7 @@ pub fn calculate_locomotive(wagons: &Vec) -> Locomotive { } pub fn wagons_loco_dists_lengths( - wagons: &Vec, + wagons: &[RollingStockID], ) -> impl DoubleEndedIterator + '_ { let mut loco_dist = 0.0; wagons.iter().map(move |&id| { @@ -89,7 +89,7 @@ pub fn wagons_loco_dists_lengths( } pub fn wagons_positions_for_render<'a>( - wagons: &'a Vec, + wagons: &'a [RollingStockID], points: &'a PolyLine3, dist: f32, ) -> impl Iterator + 'a { @@ -110,7 +110,7 @@ pub fn wagons_positions_for_render<'a>( }) } -pub fn train_length(wagons: &Vec) -> f32 { +pub fn train_length(wagons: &[RollingStockID]) -> f32 { wagons .iter() .map(|id| RollingStockID::prototype(*id).length) @@ -119,7 +119,7 @@ pub fn train_length(wagons: &Vec) -> f32 { pub fn spawn_train( sim: &mut Simulation, - wagons: &Vec, + wagons: &[RollingStockID], kind: RailWagonKind, lane: LaneID, dist: f32, @@ -168,7 +168,7 @@ pub fn spawn_train( let mut followers: Vec<_> = leader .past .mk_followers( - wagons_loco_dists_lengths(&wagons) + wagons_loco_dists_lengths(wagons) .flat_map(|(dist, length)| [dist + length * 0.1, dist + length * 0.9]), ) .collect();