Skip to content

Commit bd0d180

Browse files
committed
fix(status-area): break from loop instead of unwrapping
1 parent 79621c1 commit bd0d180

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

cosmic-applet-status-area/src/unique_names.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// but only tracking unique names, and using tokio executor.
66

77
use futures::StreamExt;
8+
use futures::stream::FusedStream;
89
use std::{
910
collections::HashSet,
1011
future::{Future, poll_fn},
@@ -36,9 +37,15 @@ impl Inner {
3637
/// Process all events so far on `stream`, and update `unique_names`.
3738
fn update_if_needed(&mut self) {
3839
let mut context = Context::from_waker(&self.waker);
39-
while let Poll::Ready(val) = self.stream.poll_next_unpin(&mut context) {
40-
let val = val.unwrap();
41-
let args = val.args().unwrap();
40+
while !self.stream.is_terminated()
41+
&& let Poll::Ready(val) = self.stream.poll_next_unpin(&mut context)
42+
{
43+
let Some(val) = val else {
44+
break;
45+
};
46+
let Ok(args) = val.args() else {
47+
break;
48+
};
4249
match args.name {
4350
BusName::Unique(name) => {
4451
if args.new_owner.is_some() {
@@ -48,7 +55,7 @@ impl Inner {
4855
}
4956
}
5057
BusName::WellKnown(_) => {}
51-
}
58+
};
5259
}
5360
}
5461
}

0 commit comments

Comments
 (0)