Use inline format args (#2232)

This commit is contained in:
Yuri Astrakhan
2023-09-19 06:51:57 +00:00
committed by GitHub
parent a9822ec80b
commit 786329d85d
35 changed files with 72 additions and 83 deletions
+5 -5
View File
@@ -100,8 +100,8 @@ async fn websocket(stream: WebSocket, state: Arc<AppState>) {
let mut rx = state.tx.subscribe();
// Now send the "joined" message to all subscribers.
let msg = format!("{} joined.", username);
tracing::debug!("{}", msg);
let msg = format!("{username} joined.");
tracing::debug!("{msg}");
let _ = state.tx.send(msg);
// Spawn the first task that will receive broadcast messages and send text
@@ -124,7 +124,7 @@ async fn websocket(stream: WebSocket, state: Arc<AppState>) {
let mut recv_task = tokio::spawn(async move {
while let Some(Ok(Message::Text(text))) = receiver.next().await {
// Add username before message.
let _ = tx.send(format!("{}: {}", name, text));
let _ = tx.send(format!("{name}: {text}"));
}
});
@@ -135,8 +135,8 @@ async fn websocket(stream: WebSocket, state: Arc<AppState>) {
};
// Send "user left" message (similar to "joined" above).
let msg = format!("{} left.", username);
tracing::debug!("{}", msg);
let msg = format!("{username} left.");
tracing::debug!("{msg}");
let _ = state.tx.send(msg);
// Remove username from map so new clients can take it again.