Skip to content

Commit

Permalink
partial fix
Browse files Browse the repository at this point in the history
  • Loading branch information
move47 committed Mar 27, 2024
1 parent 67f34fc commit 84c9c1e
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/events_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,19 @@ impl<Types: NodeType> EventConsumer<Types> for EventsStreamer<Types> {
#[async_trait]
impl<Types: NodeType> EventsSource<Types> for EventsStreamer<Types> {
type EventStream = BoxStream<'static, Arc<BuilderEvent<Types>>>;

async fn get_event_stream(&self) -> Self::EventStream {
let recv_channel = self.to_subscribe_clone_recv.clone();

let startup_event = self.get_startup_event();
self.subscriber_send_channel
.broadcast(Arc::new(startup_event))
.await
.expect("Failed to send startup event");

let mut starup_event_initialized = false;
let startup_event = self.get_startup_event().clone();
stream::unfold(recv_channel, move |mut recv_channel| async move {
let event_res = recv_channel.recv().await;
if event_res.is_err() {
return None;
}
Some((event_res.unwrap(), recv_channel))
let event_res = if starup_event_initialized {
recv_channel.recv().await.ok()
} else {
starup_event_initialized = true;

Check failure on line 173 in src/events_source.rs

View workflow job for this annotation

GitHub Actions / clippy

value assigned to `starup_event_initialized` is never read

error: value assigned to `starup_event_initialized` is never read --> src/events_source.rs:173:17 | 173 | starup_event_initialized = true; | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: maybe it is overwritten before being read? = note: `-D unused-assignments` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unused_assignments)]`
Some(Arc::new(startup_event.clone()))
};
event_res.map(|event| (event, recv_channel))
})

Check failure on line 177 in src/events_source.rs

View workflow job for this annotation

GitHub Actions / clippy

cannot move out of `startup_event`, a captured variable in an `FnMut` closure

error[E0507]: cannot move out of `startup_event`, a captured variable in an `FnMut` closure --> src/events_source.rs:169:62 | 168 | let startup_event = self.get_startup_event().clone(); | ------------- captured outer variable 169 | stream::unfold(recv_channel, move |mut recv_channel| async move { | ______________________________________-----------------------_^ | | | | | captured by this `FnMut` closure 170 | | let event_res = if starup_event_initialized { 171 | | recv_channel.recv().await.ok() 172 | | } else { 173 | | starup_event_initialized = true; 174 | | Some(Arc::new(startup_event.clone())) | | ------------- | | | | | variable moved due to use in coroutine | | move occurs because `startup_event` has type `events_source::BuilderEvent<Types>`, which does not implement the `Copy` trait 175 | | }; 176 | | event_res.map(|event| (event, recv_channel)) 177 | | }) | |_________^ `startup_event` is moved here
.boxed()
}
Expand Down

0 comments on commit 84c9c1e

Please sign in to comment.