chore: apply recommendations from clippy

This commit is contained in:
Cheong Lau 2025-10-04 10:51:18 +10:00 committed by GitHub
parent cec55dafd7
commit 8e0f1c4a09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 720 additions and 824 deletions

View file

@ -76,7 +76,7 @@ impl StatusNotifierItem {
}
pub fn icon_subscription(&self) -> iced::Subscription<IconUpdate> {
fn icon_events<'a>(
fn icon_events(
item_proxy: StatusNotifierItemProxy<'static>,
) -> impl futures::Stream<Item = IconUpdate> + 'static {
async move {
@ -99,7 +99,7 @@ impl StatusNotifierItem {
format!("status-notifier-item-icon-{}", &self.name),
async move {
let new_icon_stream = item_proxy.receive_new_icon().await.unwrap();
futures::stream::once(async { () })
futures::stream::once(async {})
.chain(new_icon_stream.map(|_| ()))
.flat_map(move |()| icon_events(item_proxy.clone()))
}

View file

@ -33,7 +33,7 @@ pub async fn watch(connection: &zbus::Connection) -> zbus::Result<EventStream> {
let name = connection.unique_name().unwrap().as_str();
if let Err(err) = watcher.register_status_notifier_host(name).await {
eprintln!("Failed to register status notifier host: {}", err);
eprintln!("Failed to register status notifier host: {err}");
}
let connection_clone = connection.clone();

View file

@ -36,10 +36,10 @@ pub fn subscription() -> iced::Subscription<Event> {
}
Err(err) => Some((Event::Error(err.to_string()), State::Failed)),
},
State::Connected(mut stream) => match stream.next().await {
Some(event) => Some((event, State::Connected(stream))),
None => None,
},
State::Connected(mut stream) => stream
.next()
.await
.map(|event| (event, State::Connected(stream))),
State::Failed => None,
}
}),

View file

@ -33,7 +33,7 @@ impl StatusNotifierWatcher {
) {
let sender = hdr.sender().unwrap();
let service = if service.starts_with('/') {
format!("{}{}", sender, service)
format!("{sender}{service}")
} else {
service.to_string()
};
@ -95,7 +95,7 @@ pub async fn create_service(connection: &zbus::Connection) -> zbus::Result<()> {
let flags = RequestNameFlags::AllowReplacement.into();
if dbus_proxy.request_name(NAME.as_ref(), flags).await? == RequestNameReply::InQueue {
eprintln!("Bus name '{}' already owned", NAME);
eprintln!("Bus name '{NAME}' already owned");
}
let connection = connection.clone();
@ -103,18 +103,15 @@ pub async fn create_service(connection: &zbus::Connection) -> zbus::Result<()> {
let mut have_bus_name = false;
let unique_name = connection.unique_name().map(|x| x.as_ref());
while let Some(evt) = name_owner_changed_stream.next().await {
let args = match evt.args() {
Ok(args) => args,
Err(_) => {
continue;
}
let Ok(args) = evt.args() else {
continue;
};
if args.name.as_ref() == NAME {
if args.new_owner.as_ref() == unique_name.as_ref() {
eprintln!("Acquired bus name: {}", NAME);
eprintln!("Acquired bus name: {NAME}");
have_bus_name = true;
} else if have_bus_name {
eprintln!("Lost bus name: {}", NAME);
eprintln!("Lost bus name: {NAME}");
have_bus_name = false;
}
} else if let BusName::Unique(name) = &args.name {