diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 82f1c8e..07ba00e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -181,12 +181,12 @@ async fn tokio_main(conf: Config) -> Result<(), Box<dyn Error>> { .and_then(move |id: String, websocket: warp::ws::Ws, saddr: Option<SocketAddr>| { let rooms = rooms_ws.clone(); async move { - let id = RoomId {0: id}; - match rooms.read().await.get(&id).map(|x| x.clone()) { + let id = RoomId(id); + match rooms.read().await.get(&id).cloned() { Some(r) => { println!("{id} I: conn from {saddr:?}"); Ok(websocket.on_upgrade(move |socket| { - conn::lobby(socket, saddr.expect("socket without address"), (id,r.clone())) + conn::lobby(socket, saddr.expect("socket without address"), (id,r)) })) }, None => { @@ -201,7 +201,7 @@ async fn tokio_main(conf: Config) -> Result<(), Box<dyn Error>> { .then(move |id: String, f: fs::File| { let rooms = rooms_lobby.clone(); async move { - if rooms.read().await.contains_key(&RoomId {0: id}) { + if rooms.read().await.contains_key(&RoomId(id)) { f.into_response() } else { reply::with_status("No such room", http::StatusCode::BAD_REQUEST).into_response() @@ -258,7 +258,7 @@ async fn gameloop(mut move_rx: tokio::sync::mpsc::UnboundedReceiver<MetaMove>, p board_encoder.write_all(&game.board.render()).unwrap(); let compressed_board = board_encoder.finish().unwrap(); let mut reply = vec![Message::binary(compressed_board)]; - let lpname = latest_player_name.as_ref().map(|s| s.as_str()).unwrap_or("unknown player").replace(" ", " "); + let lpname = latest_player_name.as_deref().unwrap_or("unknown player").replace(' ', " "); match game.phase { Phase::Win => { reply.push(Message::text(format!("win {lpname}"))); }, Phase::Die => { reply.push(Message::text(format!("lose {lpname}"))); }, |