Skip to content

Commit

Permalink
fix: replace dyn with impl for return type
Browse files Browse the repository at this point in the history
  • Loading branch information
edfloreshz committed Dec 31, 2024
1 parent 83f9ee0 commit a4ba7ab
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/platforms/freedesktop/subscribe.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::error::Error;
use std::pin::Pin;

use ashpd::desktop::settings::Settings;
use futures::{stream, Stream, StreamExt};
Expand Down Expand Up @@ -33,24 +32,23 @@ pub fn subscribe() -> std::sync::mpsc::Receiver<Mode> {
}

#[cfg(not(feature = "sync"))]
pub async fn subscribe() -> Pin<Box<dyn Stream<Item = Mode> + Send>> {
pub async fn subscribe() -> impl Stream<Item = Mode> + Send {
match color_scheme_stream().await {
Ok(stream) => stream,
Err(err) => {
log::error!("Failed to subscribe to color scheme changes: {}", err);
Box::pin(Box::new(stream::empty()))
panic!("Failed to subscribe to color scheme changes: {}", err);
}
}
}

pub async fn color_scheme_stream(
) -> Result<Pin<Box<dyn Stream<Item = Mode> + Send>>, Box<dyn Error>> {
pub async fn color_scheme_stream() -> Result<impl Stream<Item = Mode> + Send, Box<dyn Error>> {
let initial = stream::once(super::get_color_scheme()).boxed();
let later_updates = Settings::new()
.await?
.receive_color_scheme_changed()
.await?
.map(Mode::from)
.boxed();
Ok(Box::pin(Box::new(initial.chain(later_updates))))
Ok(Box::pin(initial.chain(later_updates)))
}

0 comments on commit a4ba7ab

Please sign in to comment.