Skip to content

Commit b8d4757

Browse files
committed
Remove optional
1 parent 64f0cf6 commit b8d4757

File tree

1 file changed

+17
-28
lines changed

1 file changed

+17
-28
lines changed

databroker/src/broker.rs

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub struct QuerySubscription {
155155

156156
pub struct ChangeSubscription {
157157
entries: HashMap<i32, HashSet<Field>>,
158-
sender: Option<mpsc::Sender<EntryUpdates>>,
158+
sender: mpsc::Sender<EntryUpdates>,
159159
permissions: Permissions,
160160
}
161161

@@ -661,23 +661,18 @@ impl Subscriptions {
661661
}
662662
});
663663
self.change_subscriptions.retain_mut(|sub| {
664-
if let Some(sender) = &sub.sender {
665-
if sender.is_closed() {
666-
info!("Subscriber gone: removing subscription");
667-
false
668-
} else {
669-
match &sub.permissions.expired() {
670-
Ok(()) => true,
671-
Err(PermissionError::Expired) => {
672-
info!("Token expired: removing subscription");
673-
false
674-
}
675-
Err(err) => panic!("Error: {:?}", err),
676-
}
677-
}
678-
} else {
664+
if sub.sender.is_closed() {
679665
info!("Subscriber gone: removing subscription");
680666
false
667+
} else {
668+
match &sub.permissions.expired() {
669+
Ok(()) => true,
670+
Err(PermissionError::Expired) => {
671+
info!("Token expired: removing subscription");
672+
false
673+
}
674+
Err(err) => panic!("Error: {:?}", err),
675+
}
681676
}
682677
});
683678
}
@@ -749,13 +744,11 @@ impl ChangeSubscription {
749744
};
750745
if notifications.updates.is_empty() {
751746
Ok(())
752-
} else if let Some(sender) = &self.sender {
753-
match sender.send(notifications).await {
747+
} else {
748+
match &self.sender.send(notifications).await {
754749
Ok(()) => Ok(()),
755750
Err(_) => Err(NotificationError {}),
756751
}
757-
} else {
758-
Err(NotificationError {})
759752
}
760753
} else {
761754
Ok(())
@@ -792,13 +785,9 @@ impl ChangeSubscription {
792785
}
793786
notifications
794787
};
795-
if let Some(sender) = &self.sender {
796-
match sender.send(notifications).await {
797-
Ok(()) => Ok(()),
798-
Err(_) => Err(NotificationError {}),
799-
}
800-
} else {
801-
Err(NotificationError {})
788+
match &self.sender.send(notifications).await {
789+
Ok(()) => Ok(()),
790+
Err(_) => Err(NotificationError {}),
802791
}
803792
}
804793
}
@@ -1478,7 +1467,7 @@ impl<'a, 'b> AuthorizedAccess<'a, 'b> {
14781467
let (sender, receiver) = mpsc::channel(10);
14791468
let subscription = ChangeSubscription {
14801469
entries: valid_entries,
1481-
sender: Some(sender),
1470+
sender,
14821471
permissions: self.permissions.clone(),
14831472
};
14841473

0 commit comments

Comments
 (0)