Skip to content

Commit aa39228

Browse files
committed
fix clippy lints
1 parent f585609 commit aa39228

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

src/audio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub fn queue_managed_audio_system(
251251
},
252252
});
253253
}
254-
#[allow(clippy::for_loops_over_fallibles)]
254+
#[allow(for_loops_over_fallibles)]
255255
if let Some(item) = game_state.audio_manager.music_queue.drain(..).last() {
256256
// stop any music currently playing
257257
if let Ok((entity, music)) = music_query.get_single() {

src/keyboard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn sync_keyboard_events(
2525

2626
// Populate this frame's events
2727
for event in keyboard_input_events.read() {
28-
engine.keyboard_events.push(event.clone());
28+
engine.keyboard_events.push(*event);
2929
}
3030
}
3131

src/mouse.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn sync_mouse_events(
192192

193193
// Populate this frame's events
194194
for ev in mouse_button_events.read() {
195-
game_state.mouse_button_events.push(ev.clone());
195+
game_state.mouse_button_events.push(*ev);
196196
}
197197
for ev in cursor_moved_events.read() {
198198
let mut new_event = ev.clone();
@@ -203,12 +203,12 @@ fn sync_mouse_events(
203203
game_state.mouse_location_events.push(new_event);
204204
}
205205
for ev in mouse_motion_events.read() {
206-
let mut ev2 = ev.clone();
206+
let mut ev2 = *ev;
207207
ev2.delta.y *= -1.0;
208-
game_state.mouse_motion_events.push(ev2.clone());
208+
game_state.mouse_motion_events.push(ev2);
209209
}
210210
for ev in mouse_wheel_events.read() {
211-
game_state.mouse_wheel_events.push(ev.clone());
211+
game_state.mouse_wheel_events.push(*ev);
212212
}
213213
}
214214

@@ -225,7 +225,7 @@ fn sync_mouse_state(
225225
// Only changes when we get a new event, otherwise we preserve the last location.
226226
if let Some(event) = cursor_moved_events.read().last() {
227227
// Convert from bevy's window space to our game space
228-
let mut location = event.position.clone();
228+
let mut location = event.position;
229229
location.x -= game_state.window_dimensions.x * 0.5;
230230
location.y = -location.y + (game_state.window_dimensions.y * 0.5);
231231
mouse_state.location = Some(location);
@@ -235,7 +235,7 @@ fn sync_mouse_state(
235235
for ev in mouse_motion_events.read() {
236236
// Convert motion to game space direction (positive y is up, not down)
237237
// TODO: Check to see if this needs to be adjusted for different DPIs
238-
let mut ev2 = ev.clone();
238+
let mut ev2 = *ev;
239239
ev2.delta.y *= -1.0;
240240
mouse_state.motion += ev2.delta;
241241
}

src/physics.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,13 @@ fn collision_detection(
172172
/// Represents the collider (or lack thereof) of a sprite. Two sprites need to have colliders AND
173173
/// have their `Sprite.collision` fields set to `true` to generate collision events. See the
174174
/// `collider` example to create your own colliders
175-
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
175+
#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq)]
176176
pub enum Collider {
177+
#[default]
177178
NoCollider,
178179
Poly(Vec<Vec2>),
179180
}
180181

181-
impl Default for Collider {
182-
fn default() -> Self {
183-
Collider::NoCollider
184-
}
185-
}
186-
187182
impl Collider {
188183
/// Generate a rectangular collider based on top-left and bottom-right points
189184
pub fn rect<T: Into<Vec2>>(topleft: T, bottomright: T) -> Self {
@@ -341,7 +336,7 @@ impl Collider {
341336
let poly2 = sprite2.collider.relative_to(sprite2);
342337
// Polygon intersection algorithm adapted from
343338
// https://stackoverflow.com/questions/10962379/how-to-check-intersection-between-2-rotated-rectangles
344-
for poly in vec![poly1.clone(), poly2.clone()] {
339+
for poly in [poly1.clone(), poly2.clone()] {
345340
for (idx, &p1) in poly.iter().enumerate() {
346341
let p2 = poly[(idx + 1) % poly.len()];
347342
let normal = Vec2::new(p2.y - p1.y, p1.x - p2.x);

0 commit comments

Comments
 (0)