Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace raw subtraction w/ checked_sub #2418

Merged
merged 1 commit into from
Dec 19, 2024
Merged

Conversation

tbro
Copy link
Contributor

@tbro tbro commented Dec 19, 2024

This PR:

Replaces a raw u64 - 1 with checked_sub(). I noticed some tests were panicking here, and I think handling this is best practice even if we don't think we will hit it. Especially since the fn where this is happening already returns anyhow::Result, so we don't need to refactor anything.

I put the integer being subtracted from in the error to distinguish from rust panic message.

I put the integer being subtracted from in the error to distinguish
from rust panic message.
@tbro tbro marked this pull request as ready for review December 19, 2024 12:20
@tbro tbro changed the title Do a checked_sub instead. Replace raw subtraction w/ checked_sub Dec 19, 2024
@tbro tbro merged commit f68a58e into main Dec 19, 2024
22 checks passed
@tbro tbro deleted the tb/fix/subtract-with-overflow branch December 19, 2024 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants