diff --git a/back_end/src/json_handlers.rs b/back_end/src/json_handlers.rs index 4a3ee17..cbccb1b 100644 --- a/back_end/src/json_handlers.rs +++ b/back_end/src/json_handlers.rs @@ -10,9 +10,7 @@ pub fn handle_json(root: Value) -> Result { "disconnect" => handle_disconnect(root), "request_board_state" => handle_request_board_state(root), "game_state" => handle_game_state(root), - _ => { - Err("{\"type\":\"invalid_type\"}".into()) - } + _ => Err("{\"type\":\"invalid_type\"}".into()), } } else { Err("{\"type\":\"invalid_json\"}".into()) diff --git a/back_end/src/main.rs b/back_end/src/main.rs index ee63d03..65a9759 100644 --- a/back_end/src/main.rs +++ b/back_end/src/main.rs @@ -9,16 +9,8 @@ async fn main() { .and(warp::body::json()) .map(|json_value: Value| { let result = json_handlers::handle_json(json_value); - if let Ok(result_str) = result { - result_str - } else if let Err(error_str) = result { - error_str - } else { - unreachable!() - } + result.unwrap_or_else(|e| e) }); - warp::serve(route) - .run(([0,0,0,0], 1237)) - .await; + warp::serve(route).run(([0, 0, 0, 0], 1237)).await; }