Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriopass committed Jul 11, 2024
1 parent fb871fc commit f182a87
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions native_app/src/gui/hud/keybinds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down
18 changes: 9 additions & 9 deletions native_app/src/gui/hud/toolbox/building.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
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,
RenderAsset,
};
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;

Expand Down
8 changes: 4 additions & 4 deletions simulation/src/map/objects/intersection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}

Expand All @@ -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)
}

Expand Down
12 changes: 6 additions & 6 deletions simulation/src/transportation/train.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct RailWagon {
pub rolling_stock: RollingStockID,
}

pub fn calculate_locomotive(wagons: &Vec<RollingStockID>) -> 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| {
Expand All @@ -78,7 +78,7 @@ pub fn calculate_locomotive(wagons: &Vec<RollingStockID>) -> Locomotive {
}

pub fn wagons_loco_dists_lengths(
wagons: &Vec<RollingStockID>,
wagons: &[RollingStockID],
) -> impl DoubleEndedIterator<Item = (f32, f32)> + '_ {
let mut loco_dist = 0.0;
wagons.iter().map(move |&id| {
Expand All @@ -89,7 +89,7 @@ pub fn wagons_loco_dists_lengths(
}

pub fn wagons_positions_for_render<'a>(
wagons: &'a Vec<RollingStockID>,
wagons: &'a [RollingStockID],
points: &'a PolyLine3,
dist: f32,
) -> impl Iterator<Item = (Vec3, Vec3, f32)> + 'a {
Expand All @@ -110,7 +110,7 @@ pub fn wagons_positions_for_render<'a>(
})
}

pub fn train_length(wagons: &Vec<RollingStockID>) -> f32 {
pub fn train_length(wagons: &[RollingStockID]) -> f32 {
wagons
.iter()
.map(|id| RollingStockID::prototype(*id).length)
Expand All @@ -119,7 +119,7 @@ pub fn train_length(wagons: &Vec<RollingStockID>) -> f32 {

pub fn spawn_train(
sim: &mut Simulation,
wagons: &Vec<RollingStockID>,
wagons: &[RollingStockID],
kind: RailWagonKind,
lane: LaneID,
dist: f32,
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit f182a87

Please sign in to comment.