Skip to content

Commit 3e101a0

Browse files
committed
fix: change order of code to prevent panic
If attempts is set to 0 then the call to poll will return no progress possible and cause a panic
1 parent 421fe4c commit 3e101a0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/data_state_retry.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ impl<T, E: ErrorBounds> DataStateRetry<T, E> {
113113
wait_left / 1000
114114
),
115115
);
116-
if ui.button("Stop Trying").clicked() {
117-
self.attempts_left = 0;
118-
}
119116
let can_make_progress = self.start_or_poll(fetch_fn);
120117
debug_assert!(
121118
can_make_progress.is_able_to_make_progress(),
122119
"This should be able to make progress"
123120
);
121+
if ui.button("Stop Trying").clicked() {
122+
self.attempts_left = 0;
123+
}
124124
}
125125
CanMakeProgress::AbleToMakeProgress
126126
}

0 commit comments

Comments
 (0)