Skip to content

Commit

Permalink
Remove unnecessary mut references
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmittag committed Apr 23, 2024
1 parent 7033bf6 commit bba87bd
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions databroker/src/broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ impl Subscriptions {
}

pub async fn notify(
&mut self,
&self,
changed: Option<&HashMap<i32, HashSet<Field>>>,
db: &Database,
) -> Result<Option<HashMap<String, ()>>, NotificationError> {
Expand All @@ -627,7 +627,7 @@ impl Subscriptions {
}
}

for sub in &mut self.change_subscriptions {
for sub in &self.change_subscriptions {
match sub.notify(changed, db).await {
Ok(_) => {}
Err(err) => error = Some(err),
Expand Down Expand Up @@ -660,7 +660,7 @@ impl Subscriptions {
true
}
});
self.change_subscriptions.retain_mut(|sub| {
self.change_subscriptions.retain(|sub| {
if sub.sender.is_closed() {
info!("Subscriber gone: removing subscription");
false
Expand All @@ -671,7 +671,10 @@ impl Subscriptions {
info!("Token expired: removing subscription");
false
}
Err(err) => panic!("Error: {:?}", err),
Err(err) => {
info!("Error: {:?} -> removing subscription", err);
false
}
}
}
});
Expand Down Expand Up @@ -745,7 +748,7 @@ impl ChangeSubscription {
if notifications.updates.is_empty() {
Ok(())
} else {
match &self.sender.send(notifications).await {
match self.sender.send(notifications).await {
Ok(()) => Ok(()),
Err(_) => Err(NotificationError {}),
}
Expand Down Expand Up @@ -785,7 +788,7 @@ impl ChangeSubscription {
}
notifications
};
match &self.sender.send(notifications).await {
match self.sender.send(notifications).await {
Ok(()) => Ok(()),
Err(_) => Err(NotificationError {}),
}
Expand Down Expand Up @@ -1421,7 +1424,7 @@ impl<'a, 'b> AuthorizedAccess<'a, 'b> {
match self
.broker
.subscriptions
.write()
.read()
.await
.notify(Some(&changed), &db)
.await
Expand Down

0 comments on commit bba87bd

Please sign in to comment.