Skip to content

Commit

Permalink
Use &str and to_owned() to remove clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
tausifcreates committed Dec 18, 2023
1 parent f889d7e commit 202f732
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/react-rooms-chat/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ pub struct MessageStore {
}

impl MessageStore {
pub async fn insert(&self, room: &String, message: Message) {
pub async fn insert(&self, room: &str, message: Message) {
let mut binding = self.messages.write().await;
let messages = binding.entry(room.clone()).or_default();
let messages = binding.entry(room.to_owned()).or_default();
messages.push_front(message);
messages.truncate(20);
}

pub async fn get(&self, room: &String) -> Vec<Message> {
pub async fn get(&self, room: &str) -> Vec<Message> {
let messages = self.messages.read().await.get(room).cloned();
messages.unwrap_or_default().into_iter().rev().collect()
}
Expand Down

0 comments on commit 202f732

Please sign in to comment.