Skip to content

Commit 29f247d

Browse files
committed
fix: removed recursion rust-lang/rust#75667
1 parent 4adea87 commit 29f247d

File tree

3 files changed

+29
-42
lines changed

3 files changed

+29
-42
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sapter"
3-
version = "0.1.11"
3+
version = "0.1.12"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

src/lib.rs

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -123,59 +123,46 @@ impl GameState {
123123
}
124124

125125
self.open(x, y).unwrap();
126-
self.recursive_open(x, y);
126+
// self.recursive_open(x, y);
127127

128128
Ok(())
129129
}
130130

131-
fn recursive_open(&mut self, x: usize, y: usize) {
132-
let nof_mines_around = self.count_mines_around(x, y);
131+
// fn recursive_open(&mut self, x: usize, y: usize) {
132+
// let nof_mines_around = self.count_mines_around(x, y);
133133

134-
if nof_mines_around > 0 {
135-
self.open(x, y).unwrap();
136-
return;
137-
}
134+
// if nof_mines_around > 0 {
135+
// self.open(x, y).unwrap();
136+
// return;
137+
// }
138138

139-
if self.has_mine(x, y) {
140-
return;
141-
}
139+
// if self.has_mine(x, y) {
140+
// return;
141+
// }
142142

143-
if self.is_flagged(x, y) {
144-
return;
145-
}
143+
// if self.is_flagged(x, y) {
144+
// return;
145+
// }
146146

147-
self.open(x, y).unwrap();
147+
// self.open(x, y).unwrap();
148148

149-
if x > 0 && self.is_in_range(x - 1, y).is_ok() && !self.is_opened(x - 1, y) {
150-
self.recursive_open(x - 1, y);
151-
}
149+
// if x > 0 && self.is_in_range(x - 1, y).is_ok() && !self.is_opened(x - 1, y) {
150+
// self.recursive_open(x - 1, y);
151+
// }
152152

153-
if y > 0 && self.is_in_range(x, y - 1).is_ok() && !self.is_opened(x, y - 1) {
154-
self.recursive_open(x, y - 1);
155-
}
153+
// if y > 0 && self.is_in_range(x, y - 1).is_ok() && !self.is_opened(x, y - 1) {
154+
// self.recursive_open(x, y - 1);
155+
// }
156156

157-
if self.is_in_range(x + 1, y).is_ok() && !self.is_opened(x + 1, y) {
158-
self.recursive_open(x + 1, y);
159-
}
157+
// if self.is_in_range(x + 1, y).is_ok() && !self.is_opened(x + 1, y) {
158+
// self.recursive_open(x + 1, y);
159+
// }
160160

161-
if self.is_in_range(x, y + 1).is_ok() && !self.is_opened(x, y + 1) {
162-
self.recursive_open(x, y + 1);
163-
}
161+
// if self.is_in_range(x, y + 1).is_ok() && !self.is_opened(x, y + 1) {
162+
// self.recursive_open(x, y + 1);
163+
// }
164164

165-
// let min_x = if x == 0 { 0 } else { x - 1 };
166-
// let min_y = if y == 0 { 0 } else { y - 1 };
167-
// let max_x = if x >= self.width { self.width } else { x + 1 };
168-
// let max_y = if y >= self.height { self.height } else { y + 1 };
169-
170-
// for x_it in min_x..=max_x {
171-
// for y_it in min_y..=max_y {
172-
// if !self.is_opened(x_it, y_it) {
173-
// self.open(x_it, y_it);
174-
// // self.recursive_open(x_it, y_it);
175-
// }
176-
// }
177-
// }
178-
}
165+
// }
179166

180167
pub fn mines_left(&self) -> usize {
181168
self.mines.len() - self.flags.len()

0 commit comments

Comments
 (0)