Skip to content

Commit 1ede099

Browse files
authored
Merge pull request #597 from BartMassey-upstream/compile-warnings
fixed compiler warnings in snake-game
2 parents 29de542 + c79f8fb commit 1ede099

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

microbit/src/11-snake-game/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ optional = true
1717
[dependencies]
1818
cortex-m = "0.7.3"
1919
cortex-m-rt = "0.7.0"
20-
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
21-
panic-rtt-target = { version = "0.1.2", features = ["cortex-m"] }
2220
lsm303agr = "0.2.2"
2321
nb = "1.0.0"
2422
libm = "0.2.1"
2523
heapless = "0.8.0"
2624
tiny-led-matrix = "1.0.1"
25+
rtt-target = "0.6.1"
26+
panic-rtt-target = "0.2.0"
2727

2828
[features]
2929
v2 = ["microbit-v2"]

microbit/src/11-snake-game/src/game.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ pub enum GameStatus {
8888
/// The outcome of a single move/step.
8989
enum StepOutcome {
9090
/// Grid full (player wins)
91-
Full(Coords),
91+
Full,
9292
/// Snake has collided with itself (player loses)
93-
Collision(Coords),
93+
Collision,
9494
/// Snake has eaten some food
9595
Eat(Coords),
9696
/// Snake has moved (and nothing else has happened)
@@ -248,13 +248,13 @@ impl Game {
248248
// won't actually be any collision (as the tail will have moved by the time the head
249249
// moves onto the tile)
250250
if next_move != *self.snake.tail.peek().unwrap() {
251-
StepOutcome::Collision(next_move)
251+
StepOutcome::Collision
252252
} else {
253253
StepOutcome::Move(next_move)
254254
}
255255
} else if next_move == self.food_coords {
256256
if self.snake.tail.len() == 23 {
257-
StepOutcome::Full(next_move)
257+
StepOutcome::Full
258258
} else {
259259
StepOutcome::Eat(next_move)
260260
}
@@ -266,8 +266,8 @@ impl Game {
266266
/// Handle the outcome of a step, updating the game's internal state.
267267
fn handle_step_outcome(&mut self, outcome: StepOutcome) {
268268
self.status = match outcome {
269-
StepOutcome::Collision(_) => GameStatus::Lost,
270-
StepOutcome::Full(_) => GameStatus::Won,
269+
StepOutcome::Collision => GameStatus::Lost,
270+
StepOutcome::Full => GameStatus::Won,
271271
StepOutcome::Eat(c) => {
272272
self.snake.move_snake(c, true);
273273
self.place_food();
@@ -333,4 +333,4 @@ impl Game {
333333
}
334334
values
335335
}
336-
}
336+
}

microbit/src/11-snake-game/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::game::{Game, GameStatus};
2222
#[entry]
2323
fn main() -> ! {
2424
rtt_init_print!();
25-
let mut board = Board::take().unwrap();
25+
let board = Board::take().unwrap();
2626
let mut timer = Timer::new(board.TIMER0).into_periodic();
2727
let mut rng = Rng::new(board.RNG);
2828
let mut game = Game::new(rng.random_u32());

0 commit comments

Comments
 (0)