From 9a745bb56d592f9b02f94c1d681fe607670fae02 Mon Sep 17 00:00:00 2001 From: stale Date: Thu, 30 Jun 2022 07:18:45 -0300 Subject: clippy fixes and version bump --- src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/main.rs') 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> { .and_then(move |id: String, websocket: warp::ws::Ws, saddr: Option| { 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> { .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, 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}"))); }, -- cgit v1.2.3