Skip to content

Commit df02fa6

Browse files
committed
!
1 parent be048b9 commit df02fa6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

examples/proof-of-concept/src/sse.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ impl SseBroadcaster {
2222
}
2323

2424
/// Subscribe to events
25+
#[allow(dead_code)]
2526
pub fn subscribe(&self) -> broadcast::Receiver<BookmarkEvent> {
2627
self.sender.subscribe()
2728
}

examples/proof-of-concept/src/stores.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ impl UserStore {
8181
}
8282

8383
/// Find user by ID
84+
#[allow(dead_code)]
8485
pub async fn find_by_id(&self, id: u64) -> Option<User> {
8586
let users = self.users.read().await;
8687
users.get(&id).cloned()
@@ -151,8 +152,8 @@ impl BookmarkStore {
151152
/// Update a bookmark
152153
pub async fn update(&self, id: u64, bookmark: Bookmark) -> Option<Bookmark> {
153154
let mut bookmarks = self.bookmarks.write().await;
154-
if bookmarks.contains_key(&id) {
155-
bookmarks.insert(id, bookmark.clone());
155+
if let std::collections::hash_map::Entry::Occupied(mut e) = bookmarks.entry(id) {
156+
e.insert(bookmark.clone());
156157
Some(bookmark)
157158
} else {
158159
None
@@ -253,8 +254,8 @@ impl CategoryStore {
253254
/// Update a category
254255
pub async fn update(&self, id: u64, category: Category) -> Option<Category> {
255256
let mut categories = self.categories.write().await;
256-
if categories.contains_key(&id) {
257-
categories.insert(id, category.clone());
257+
if let std::collections::hash_map::Entry::Occupied(mut e) = categories.entry(id) {
258+
e.insert(category.clone());
258259
Some(category)
259260
} else {
260261
None

0 commit comments

Comments
 (0)