From c76b13784235c6ab08fa98b4ba5d58ca91d1e345 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Mon, 28 Oct 2024 17:49:17 +0100 Subject: [PATCH] fix: be explicit on used generic types and lifetimes --- Cargo.toml | 2 +- examples/sliding-puzzle.rs | 2 +- src/grid.rs | 2 +- src/lib.rs | 2 +- src/matrix.rs | 8 ++++---- tests/pathfinding.rs | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9fbc6e77..07c6409d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ authors = ["Samuel Tardieu "] categories = ["algorithms"] readme = "README.md" edition = "2021" -rust-version = "1.77.2" +rust-version = "1.82.0" [package.metadata.release] sign-commit = true diff --git a/examples/sliding-puzzle.rs b/examples/sliding-puzzle.rs index 79ee9921..abf09364 100644 --- a/examples/sliding-puzzle.rs +++ b/examples/sliding-puzzle.rs @@ -95,7 +95,7 @@ impl Game { // However, since the successors are the current board with the hole moved one // position, we need to build a clone of the current board that will be reused in // this iterator. - fn successors(&self) -> impl Iterator { + fn successors(&self) -> impl Iterator + use<> { let game = self.clone(); SUCCESSORS[self.hole_idx as usize] .iter() diff --git a/src/grid.rs b/src/grid.rs index 316d59b3..63912c0e 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -214,7 +214,7 @@ impl Grid { /// Return an iterator over the border vertices. The grid must not have /// a zero width or height. - fn borders(&self) -> impl Iterator { + fn borders(&self) -> impl Iterator + use<> { let width = self.width; let height = self.height; (0..width) diff --git a/src/lib.rs b/src/lib.rs index 62183b81..cf5eddd6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,7 +74,7 @@ //! in this context, you can wrap them into compliant types using the //! [ordered-float](https://crates.io/crates/ordered-float) crate. //! -//! The minimum supported Rust version (MSRV) is Rust 1.77.2. +//! The minimum supported Rust version (MSRV) is Rust 1.82.0. //! //! [A*]: https://en.wikipedia.org/wiki/A*_search_algorithm //! [BFS]: https://en.wikipedia.org/wiki/Breadth-first_search diff --git a/src/matrix.rs b/src/matrix.rs index 0b71c1ef..43c33b1d 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -531,7 +531,7 @@ impl Matrix { &self, (r, c): (usize, usize), diagonals: bool, - ) -> impl Iterator { + ) -> impl Iterator + use { let (row_range, col_range) = if r < self.rows && c < self.columns { ( r.saturating_sub(1)..(self.rows).min(r + 2), @@ -597,7 +597,7 @@ impl Matrix { &self, start: (usize, usize), direction: (isize, isize), - ) -> impl Iterator { + ) -> impl Iterator + use { in_direction(start, direction, (self.rows, self.columns)) } @@ -628,14 +628,14 @@ impl Matrix { since = "4.1.0", remove = "> 4.x" )] - pub fn indices(&self) -> impl Iterator { + pub fn indices(&self) -> impl Iterator + use { self.keys() } /// Return an iterator on the Matrix indices, first row first. The values are /// computed when this method is called and will not change even if new rows are /// added before the iterator is consumed. - pub fn keys(&self) -> impl Iterator { + pub fn keys(&self) -> impl Iterator + use { let columns = self.columns; (0..self.rows).flat_map(move |r| (0..columns).map(move |c| (r, c))) } diff --git a/tests/pathfinding.rs b/tests/pathfinding.rs index 2248454a..e27c986f 100644 --- a/tests/pathfinding.rs +++ b/tests/pathfinding.rs @@ -4,7 +4,7 @@ mod ex1 { use pathfinding::prelude::*; #[allow(clippy::trivially_copy_pass_by_ref)] - fn successors(node: &u8) -> impl Iterator { + fn successors(node: &u8) -> impl Iterator + use<> { lazy_static! { static ref SUCCESSORS: Vec> = vec![ vec![(1, 7), (2, 7), (3, 6)],