From 214da65db5dfbb0c7795039dca9bd5eb8057938a Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Wed, 20 Aug 2025 14:18:52 -0500 Subject: [PATCH] Switch off deprecated functions, fix clippy lints --- src/birdoids_plugin.rs | 4 ++-- src/debug_plugin.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/birdoids_plugin.rs b/src/birdoids_plugin.rs index c6b41829..d236ac47 100644 --- a/src/birdoids_plugin.rs +++ b/src/birdoids_plugin.rs @@ -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 diff --git a/src/debug_plugin.rs b/src/debug_plugin.rs index 123c8be9..bbdf6a40 100644 --- a/src/debug_plugin.rs +++ b/src/debug_plugin.rs @@ -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>, ) { // 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>) { - 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 => {