format the code i modified

This commit is contained in:
artemis 2019-12-17 21:07:13 -08:00
parent 45e5505c9c
commit 2af22fc7d2
1 changed files with 12 additions and 7 deletions

View File

@ -72,7 +72,10 @@ fn find_path(
}
#[post("/move", format = "json", data = "<msg>")]
fn make_move(cache_state: State<Cache>, msg: Json<battlesnake::SnakeRequest>) -> Json<battlesnake::MoveResponse> {
fn make_move(
cache_state: State<Cache>,
msg: Json<battlesnake::SnakeRequest>,
) -> Json<battlesnake::MoveResponse> {
let head = msg.you.body[0];
let mut cache = cache_state.lock().expect("wanted cache to be unlockable");
@ -88,12 +91,14 @@ fn make_move(cache_state: State<Cache>, msg: Json<battlesnake::SnakeRequest>) ->
Json(battlesnake::MoveResponse {
move_field: "up".to_string(),
})
},
}
Some(next) => Json(battlesnake::MoveResponse {
move_field: battlesnake::Line {
start: &head,
end: &next,
}.direction().to_string(),
}
.direction()
.to_string(),
}),
}
}