Skip to content

Commit 94f6606

Browse files
committed
Fix lints
1 parent 6a9d106 commit 94f6606

File tree

7 files changed

+26
-26
lines changed

7 files changed

+26
-26
lines changed

src/ai.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn eval_recursive(
9191

9292
if eval_next > eval {
9393
eval = eval_next;
94-
best_variation = best_variation_returned.clone();
94+
best_variation.clone_from(&best_variation_returned);
9595
if og {
9696
ai_cache.last_variation = best_variation_returned;
9797
}

src/cell.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,15 @@ impl CellCoordinates {
156156
}
157157

158158
/// Gets the diagonal that can be reached by walking in the cartesian directions consecutively,
159-
/// does not return true neigbors. The second element of the second element denotes if the new
159+
/// does not return true neighbors. The second element of the second element denotes if the new
160160
/// cell is on a different side than the first
161161
pub(crate) fn get_diagonal(
162162
&self,
163163
diagonal: (CartesianDirection, CartesianDirection),
164164
cube_side_length: u32,
165165
) -> Option<(CellCoordinates, bool)> {
166-
let Some(cell1) = self.get_cell_in_direction(diagonal.0, cube_side_length) else {
167-
return None;
168-
};
169-
let Some(cell2) = cell1.0.get_cell_in_direction(diagonal.1, cube_side_length) else {
170-
return None;
171-
};
166+
let cell1 = self.get_cell_in_direction(diagonal.0, cube_side_length)?;
167+
let cell2 = cell1.0.get_cell_in_direction(diagonal.1, cube_side_length)?;
172168
if cell1.1 && cell2.1 {
173169
// The second element tells us if the transformation went over a cube edge, in this
174170
// case we are in a corner, which means we have a true neighbor in cell2

src/cube_rotation.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ impl RotationState {
5858
}
5959
}
6060

61+
#[allow(unused)]
6162
/// Panics in some cases if the rotation state is not possible. That is, if the side and top are parallel
6263
fn get_see_direction(&self, see_direction: SeeDirection) -> CartesianDirection {
6364
match see_direction {
@@ -172,7 +173,11 @@ fn input_handling(input: Res<Input<KeyCode>>, rotation_data: &mut RotationData)
172173
}
173174

174175
/// @param see_direction: The side (seen from the camera) that this rotation is rotating around
175-
fn start_rotation(rotation_data: &mut RotationData, rotation: CartesianDirection, _see_direction: SeeDirection) {
176+
fn start_rotation(
177+
rotation_data: &mut RotationData,
178+
rotation: CartesianDirection,
179+
_see_direction: SeeDirection,
180+
) {
176181
// If the rotation axis is not parallel to the top axis, then this rotation will modify the side axis
177182
if !rotation.is_parallel_to(rotation_data.future_rotation_state.side) {
178183
let target = rotation_data
@@ -217,7 +222,8 @@ fn total_animation_rotation(
217222
fn camera_up_vector(rotation_data: &RotationData, rotation_time: Duration) -> Vec3 {
218223
let mut output = rotation_data.rotation_state.top.as_vec3();
219224
for animation in &rotation_data.animations {
220-
if (animation.side_changing == SeeDirection::Top || animation.side_changing == SeeDirection::Bottom)
225+
if (animation.side_changing == SeeDirection::Top
226+
|| animation.side_changing == SeeDirection::Bottom)
221227
&& animation.target != animation.from
222228
{
223229
output += animation.camera_up_vector(rotation_time) - animation.from.as_vec3();
@@ -237,11 +243,18 @@ fn rotation_curve(time: f32) -> f32 {
237243

238244
let c1 = 1.70158;
239245
let c3 = c1 + 1.;
240-
246+
241247
1. + c3 * (time - 1.).powi(3) + c1 * (time - 1.).powi(2)
242248
}
243249

250+
#[allow(unused_imports)]
244251
mod tests {
252+
use std::time::Duration;
253+
254+
use bevy::math::Quat;
255+
256+
use super::*;
257+
245258
#[test]
246259
fn rotation_state_after_rotation_test() {
247260
use super::RotationState;
@@ -252,10 +265,6 @@ mod tests {
252265
RotationState { top: X, side: Z }
253266
);
254267
}
255-
256-
use super::*;
257-
use bevy::math::Quat;
258-
use std::time::Duration;
259268

260269
#[test]
261270
fn total_animation_rotation_with_no_animations() {
@@ -264,4 +273,4 @@ mod tests {
264273
let result = total_animation_rotation(&animations, rotation_time);
265274
assert_eq!(result, Quat::IDENTITY);
266275
}
267-
}
276+
}

src/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ fn main() {
4040

4141
#[derive(Component)]
4242
struct MainCamera {
43-
start_coords: Vec3,
4443
}
4544

4645
fn setup(
@@ -66,7 +65,7 @@ fn setup(
6665
commands.spawn((
6766
PointLightBundle {
6867
point_light: PointLight {
69-
intensity: 9000.0,
68+
intensity: 5000.0,
7069
range: 100.,
7170
shadows_enabled: false,
7271
..default()
@@ -75,7 +74,6 @@ fn setup(
7574
..default()
7675
},
7776
MainCamera {
78-
start_coords: Vec3::new(8., 8., 8.),
7977
},
8078
));
8179

@@ -86,7 +84,6 @@ fn setup(
8684
},
8785
RaycastPickCamera::default(), // Enable picking with this camera
8886
MainCamera {
89-
start_coords: Vec3::new(2., 2., 2.),
9087
},
9188
));
9289
}

src/movement.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub(crate) struct GameMove {
1212
}
1313

1414
impl GameMove {
15+
#[allow(unused)]
1516
pub(crate) fn display_with_unit(&self, unit: Option<&Unit>) -> String {
1617
let mut output = String::new();
1718
if let Some(unit) = unit {

src/units.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ impl Units {
180180
}
181181

182182
pub(crate) fn remove_unit(&mut self, coords: CellCoordinates) -> Option<Unit> {
183-
let Some(index) = self.units.iter().position(|unit| unit.coords==coords) else {
184-
return None;
185-
};
183+
let index = self.units.iter().position(|unit| unit.coords==coords)?;
186184

187185
Some(self.units.swap_remove(index))
188186
}

src/utils.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ impl CartesianDirection {
171171
return None;
172172
}
173173

174-
let Some(axis_num) = first_nonzero_component(vec) else {
175-
return None;
176-
};
174+
let axis_num = first_nonzero_component(vec)?;
177175

178176
Some(Self::from_axis_num(
179177
axis_num,
@@ -274,6 +272,7 @@ impl CartesianDirection {
274272
}
275273

276274
/// Signifies the direction seen from the camera.
275+
#[allow(unused)]
277276
#[derive(Debug, Clone, Copy, PartialEq)]
278277
pub(crate) enum SeeDirection {
279278
Top,

0 commit comments

Comments
 (0)