Skip to content

Commit cfe625e

Browse files
committed
fix: be explicit on used generic types and lifetimes
1 parent 415757f commit cfe625e

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

examples/sliding-puzzle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl Game {
9595
// However, since the successors are the current board with the hole moved one
9696
// position, we need to build a clone of the current board that will be reused in
9797
// this iterator.
98-
fn successors(&self) -> impl Iterator<Item = (Self, u8)> {
98+
fn successors(&self) -> impl Iterator<Item = (Self, u8)> + use<> {
9999
let game = self.clone();
100100
SUCCESSORS[self.hole_idx as usize]
101101
.iter()

src/grid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl Grid {
214214

215215
/// Return an iterator over the border vertices. The grid must not have
216216
/// a zero width or height.
217-
fn borders(&self) -> impl Iterator<Item = (usize, usize)> {
217+
fn borders(&self) -> impl Iterator<Item = (usize, usize)> + use<> {
218218
let width = self.width;
219219
let height = self.height;
220220
(0..width)

src/matrix.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ impl<C> Matrix<C> {
531531
&self,
532532
(r, c): (usize, usize),
533533
diagonals: bool,
534-
) -> impl Iterator<Item = (usize, usize)> {
534+
) -> impl Iterator<Item = (usize, usize)> + use<C> {
535535
let (row_range, col_range) = if r < self.rows && c < self.columns {
536536
(
537537
r.saturating_sub(1)..(self.rows).min(r + 2),
@@ -597,7 +597,7 @@ impl<C> Matrix<C> {
597597
&self,
598598
start: (usize, usize),
599599
direction: (isize, isize),
600-
) -> impl Iterator<Item = (usize, usize)> {
600+
) -> impl Iterator<Item = (usize, usize)> + use<C> {
601601
in_direction(start, direction, (self.rows, self.columns))
602602
}
603603

@@ -628,14 +628,14 @@ impl<C> Matrix<C> {
628628
since = "4.1.0",
629629
remove = "> 4.x"
630630
)]
631-
pub fn indices(&self) -> impl Iterator<Item = (usize, usize)> {
631+
pub fn indices(&self) -> impl Iterator<Item = (usize, usize)> + use<C> {
632632
self.keys()
633633
}
634634

635635
/// Return an iterator on the Matrix indices, first row first. The values are
636636
/// computed when this method is called and will not change even if new rows are
637637
/// added before the iterator is consumed.
638-
pub fn keys(&self) -> impl Iterator<Item = (usize, usize)> {
638+
pub fn keys(&self) -> impl Iterator<Item = (usize, usize)> + use<C> {
639639
let columns = self.columns;
640640
(0..self.rows).flat_map(move |r| (0..columns).map(move |c| (r, c)))
641641
}

tests/pathfinding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mod ex1 {
44
use pathfinding::prelude::*;
55

66
#[expect(clippy::trivially_copy_pass_by_ref)]
7-
fn successors(node: &u8) -> impl Iterator<Item = (u8, usize)> {
7+
fn successors(node: &u8) -> impl Iterator<Item = (u8, usize)> + use<> {
88
lazy_static! {
99
static ref SUCCESSORS: Vec<Vec<(u8, usize)>> = vec![
1010
vec![(1, 7), (2, 7), (3, 6)],

0 commit comments

Comments
 (0)