Skip to content

Commit

Permalink
fix: change order of code to prevent panic
Browse files Browse the repository at this point in the history
If attempts is set to 0 then the call to poll will return no progress
possible and cause a panic
  • Loading branch information
c-git committed Jan 17, 2025
1 parent 421fe4c commit 3e101a0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/data_state_retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ impl<T, E: ErrorBounds> DataStateRetry<T, E> {
wait_left / 1000
),
);
if ui.button("Stop Trying").clicked() {
self.attempts_left = 0;
}
let can_make_progress = self.start_or_poll(fetch_fn);
debug_assert!(
can_make_progress.is_able_to_make_progress(),
"This should be able to make progress"
);
if ui.button("Stop Trying").clicked() {
self.attempts_left = 0;
}
}
CanMakeProgress::AbleToMakeProgress
}
Expand Down

0 comments on commit 3e101a0

Please sign in to comment.