From 84e4a77488ea53ec5c2cd716c94725900d87b125 Mon Sep 17 00:00:00 2001 From: vil02 <65706193+vil02@users.noreply.github.com> Date: Mon, 13 Jan 2025 17:10:09 +0100 Subject: [PATCH] style: include `needless_pass_by_ref_mut` --- Cargo.toml | 1 - src/backtracking/rat_in_maze.rs | 4 ++-- src/string/z_algorithm.rs | 5 ++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 12e6fed2e2c..d65b97de92d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -164,7 +164,6 @@ suboptimal_flops = { level = "allow", priority = 1 } suspicious_operation_groupings = { level = "allow", priority = 1 } use_self = { level = "allow", priority = 1 } while_float = { level = "allow", priority = 1 } -needless_pass_by_ref_mut = { level = "allow", priority = 1 } too_long_first_doc_paragraph = { level = "allow", priority = 1 } # cargo-lints: cargo_common_metadata = { level = "allow", priority = 1 } diff --git a/src/backtracking/rat_in_maze.rs b/src/backtracking/rat_in_maze.rs index 3a3d05601cb..fb658697b39 100644 --- a/src/backtracking/rat_in_maze.rs +++ b/src/backtracking/rat_in_maze.rs @@ -60,7 +60,7 @@ pub fn find_path_in_maze( } // If validations pass, proceed with finding the path - let mut maze_instance = Maze::new(maze.to_owned()); + let maze_instance = Maze::new(maze.to_owned()); Ok(maze_instance.find_path(start_x, start_y)) } @@ -114,7 +114,7 @@ impl Maze { /// # Returns /// /// A solution matrix if a path is found or None if not found. - fn find_path(&mut self, start_x: usize, start_y: usize) -> Option>> { + fn find_path(&self, start_x: usize, start_y: usize) -> Option>> { let mut solution = vec![vec![false; self.width()]; self.height()]; if self.solve(start_x as isize, start_y as isize, &mut solution) { Some(solution) diff --git a/src/string/z_algorithm.rs b/src/string/z_algorithm.rs index 12726622793..a2825e02ddc 100644 --- a/src/string/z_algorithm.rs +++ b/src/string/z_algorithm.rs @@ -42,7 +42,7 @@ fn calculate_z_value( /// # Returns /// The initialized Z-array value for the current index. fn initialize_z_array_from_previous_match( - z_array: &mut [usize], + z_array: &[usize], i: usize, match_end: usize, last_match: usize, @@ -92,8 +92,7 @@ fn match_with_z_array( for i in start_index..size { if i <= match_end { - z_array[i] = - initialize_z_array_from_previous_match(&mut z_array, i, match_end, last_match); + z_array[i] = initialize_z_array_from_previous_match(&z_array, i, match_end, last_match); } z_array[i] = calculate_z_value(input_string, pattern, i, z_array[i]);