mirror of
https://github.com/actix/examples
synced 2025-06-26 17:17:42 +02:00
s/str::to_string/str::to_owned
This commit is contained in:
@ -76,7 +76,7 @@ impl Handler<JoinRoom> for WsChatServer {
|
||||
let id = self.add_client_to_room(&room_name, None, client);
|
||||
let join_msg = format!(
|
||||
"{} joined {room_name}",
|
||||
client_name.unwrap_or_else(|| "anon".to_string()),
|
||||
client_name.unwrap_or_else(|| "anon".to_owned()),
|
||||
);
|
||||
|
||||
self.send_chat_message(&room_name, &join_msg, id);
|
||||
|
@ -64,7 +64,7 @@ impl WsChatSession {
|
||||
pub fn send_msg(&self, msg: &str) {
|
||||
let content = format!(
|
||||
"{}: {msg}",
|
||||
self.name.clone().unwrap_or_else(|| "anon".to_string()),
|
||||
self.name.clone().unwrap_or_else(|| "anon".to_owned()),
|
||||
);
|
||||
|
||||
let msg = SendMessage(self.room.clone(), self.id, content);
|
||||
@ -84,7 +84,7 @@ impl Actor for WsChatSession {
|
||||
fn stopped(&mut self, _ctx: &mut Self::Context) {
|
||||
log::info!(
|
||||
"WsChatSession closed for {}({}) in room {}",
|
||||
self.name.clone().unwrap_or_else(|| "anon".to_string()),
|
||||
self.name.clone().unwrap_or_else(|| "anon".to_owned()),
|
||||
self.id,
|
||||
self.room
|
||||
);
|
||||
|
Reference in New Issue
Block a user