Switch off deprecated functions, fix clippy lints

This commit is contained in:
2025-08-20 14:18:52 -05:00
parent 325e515a7b
commit 214da65db5
2 changed files with 8 additions and 8 deletions

View File

@@ -171,7 +171,7 @@ fn check_keyboard(
dir.y += 1.0;
}
**pvelocity = **pvelocity + dir.extend(0.0);
**pvelocity += dir.extend(0.0);
}
fn cohesion(
@@ -231,7 +231,7 @@ fn alignment(
let neighbors = spatial_tree.within_distance(transform.translation.xy(), BOID_VIEW_RANGE);
// averaging divides by length. Guard against an empty set of neighbors
// so that we don't divide by zero.
if neighbors.len() > 0 {
if !neighbors.is_empty() {
if let Some(avg_velocity) =
velocity_of_boids(neighbors.iter().map(|(vel, opt_entity)| {
// I've observed no panics in the old version, nor the debug_plugins version

View File

@@ -66,8 +66,8 @@ fn update_cursor(
) {
// I'm trusting that only one thing has the `Cursor` component
// It's defined here in this module, so that *should* be the case...
let win = window.get_single().unwrap();
let (cam, cam_transform) = camera.get_single().unwrap();
let win = window.single().unwrap();
let (cam, cam_transform) = camera.single().unwrap();
// the cursor might not be on the window. Only adjust position when it is.
if let Some(cursor_pos_in_window) = win.cursor_position() {
// transform the window position into world space
@@ -76,7 +76,7 @@ fn update_cursor(
let cursor_in_world = cam
.viewport_to_world_2d(cam_transform, cursor_pos_in_window)
.unwrap();
let mut cursor = cursor_query.get_single_mut().unwrap();
let mut cursor = cursor_query.single_mut().unwrap();
cursor.translation = cursor_in_world.extend(0.0);
}
}
@@ -89,7 +89,7 @@ fn update_scanner_mode(
mut scanner_query: Query<(&mut SelectionMode, &mut ScannerMode), With<Cursor>>,
) {
// I'm making another assertion that there is exactly one scanner.
let (mut select_mode, mut scan_mode) = scanner_query.get_single_mut().unwrap();
let (mut select_mode, mut scan_mode) = scanner_query.single_mut().unwrap();
// Assign selection mode
if keycodes.just_pressed(KeyCode::Digit1) {
@@ -107,7 +107,7 @@ fn update_scanner_mode(
}
fn print_gizmo_config(query: Query<(&SelectionMode, &ScannerMode), With<Cursor>>) {
let (select, scan) = query.get_single().unwrap();
let (select, scan) = query.single().unwrap();
println!("Selection: {select:?}, Scanning: {scan:?}");
}
@@ -118,7 +118,7 @@ fn do_scan(
/* Push info to summary somewhere */
mut gizmos: Gizmos,
) {
let (cursor_pos, select_mode, scan_mode) = scanner_query.get_single().unwrap();
let (cursor_pos, select_mode, scan_mode) = scanner_query.single().unwrap();
match select_mode {
SelectionMode::NearestSingle => todo!(),
SelectionMode::CircularArea => {