mirror of
https://github.com/actix/examples
synced 2025-06-26 17:17:42 +02:00
Use captured args in format string (#558)
This commit is contained in:
@ -40,23 +40,23 @@ async fn main() {
|
||||
Some(msg) = framed.next() => {
|
||||
match msg {
|
||||
Ok(codec::ChatResponse::Message(ref msg)) => {
|
||||
println!("message: {}", msg);
|
||||
println!("message: {msg}");
|
||||
}
|
||||
Ok(codec::ChatResponse::Joined(ref msg)) => {
|
||||
println!("!!! joined: {}", msg);
|
||||
println!("!!! joined: {msg}");
|
||||
}
|
||||
|
||||
Ok(codec::ChatResponse::Rooms(rooms)) => {
|
||||
println!("!!! Available rooms:");
|
||||
for room in rooms {
|
||||
println!("{}", room);
|
||||
println!("{room}");
|
||||
}
|
||||
}
|
||||
|
||||
// respond to pings with a "pong"
|
||||
Ok(codec::ChatResponse::Ping) => { framed.send(codec::ChatRequest::Ping).await.unwrap(); },
|
||||
|
||||
_ => { eprintln!("{:?}", msg); }
|
||||
_ => { eprintln!("{msg:?}"); }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for WsChatSession {
|
||||
Ok(msg) => msg,
|
||||
};
|
||||
|
||||
log::debug!("WEBSOCKET MESSAGE: {:?}", msg);
|
||||
log::debug!("WEBSOCKET MESSAGE: {msg:?}");
|
||||
match msg {
|
||||
ws::Message::Ping(msg) => {
|
||||
self.hb = Instant::now();
|
||||
@ -168,11 +168,11 @@ impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for WsChatSession {
|
||||
ctx.text("!!! name is required");
|
||||
}
|
||||
}
|
||||
_ => ctx.text(format!("!!! unknown command: {:?}", m)),
|
||||
_ => ctx.text(format!("!!! unknown command: {m:?}")),
|
||||
}
|
||||
} else {
|
||||
let msg = if let Some(ref name) = self.name {
|
||||
format!("{}: {}", name, m)
|
||||
format!("{name}: {m}")
|
||||
} else {
|
||||
m.to_owned()
|
||||
};
|
||||
|
@ -102,7 +102,7 @@ impl StreamHandler<Result<ChatRequest, io::Error>> for ChatSession {
|
||||
// so actor wont receive any new messages until it get list of rooms back
|
||||
}
|
||||
Ok(ChatRequest::Join(name)) => {
|
||||
println!("Join to room: {}", name);
|
||||
println!("Join to room: {name}");
|
||||
self.room = name.clone();
|
||||
self.addr.do_send(server::Join {
|
||||
id: self.id,
|
||||
@ -112,7 +112,7 @@ impl StreamHandler<Result<ChatRequest, io::Error>> for ChatSession {
|
||||
}
|
||||
Ok(ChatRequest::Message(message)) => {
|
||||
// send message to chat server
|
||||
println!("Peer message: {}", message);
|
||||
println!("Peer message: {message}");
|
||||
self.addr.do_send(server::Message {
|
||||
id: self.id,
|
||||
msg: message,
|
||||
|
Reference in New Issue
Block a user