format the code i modified
This commit is contained in:
parent
45e5505c9c
commit
2af22fc7d2
19
src/main.rs
19
src/main.rs
|
@ -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(),
|
||||
}
|
||||
Some(next) => Json(battlesnake::MoveResponse {
|
||||
move_field: battlesnake::Line {
|
||||
start: &head,
|
||||
end: &next,
|
||||
}
|
||||
.direction()
|
||||
.to_string(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue