Skip to content

Commit

Permalink
Fix for rust <1.51
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannesd3 committed May 26, 2021
1 parent 40b474b commit a04b86a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions core/src/dealer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
mod maps;
mod protocol;

use std::array;
use std::iter;
use std::pin::Pin;
use std::sync::atomic::AtomicBool;
Expand Down Expand Up @@ -543,23 +542,23 @@ async fn run<F, Fut>(
let init_task = |t| Some(TimeoutOnDrop::new(t, Duration::from_secs(3)));

let mut tasks = if let Some((s, r)) = initial_tasks {
[init_task(s), init_task(r)]
(init_task(s), init_task(r))
} else {
[None, None]
(None, None)
};

while !shared.is_closed() {
match &mut tasks {
[Some(t0), Some(t1)] => {
(Some(t0), Some(t1)) => {
select! {
() = shared.closed() => break,
r = t0 => {
r.unwrap(); // Whatever has gone wrong (probably panicked), we can't handle it, so let's panic too.
tasks[0] = None;
tasks.0.take();
},
r = t1 => {
r.unwrap();
tasks[1] = None;
tasks.1.take();
}
}
}
Expand All @@ -572,7 +571,7 @@ async fn run<F, Fut>(
};

match connect(&url, proxy.as_ref(), &shared).await {
Ok((s, r)) => tasks = [init_task(s), init_task(r)],
Ok((s, r)) => tasks = (init_task(s), init_task(r)),
Err(e) => {
warn!("Error while connecting: {}", e);
}
Expand All @@ -581,7 +580,7 @@ async fn run<F, Fut>(
}
}

let tasks = array::IntoIter::new(tasks).flatten();
let tasks = tasks.0.into_iter().chain(tasks.1);

let _ = join_all(tasks).await;
}

0 comments on commit a04b86a

Please sign in to comment.