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

Use wrapping_add to prevent error on debug mode #4

Merged
merged 2 commits into from
Sep 13, 2023
Merged

Conversation

vbkaisetsu
Copy link
Member

The current double-array trie implementation uses i32::MAX for the invalid base value, so that bases.get(base+char) always returns None.
However, using the normal addition operator (+) for addition causes panic with the message attempt to add with overflow in debug mode when overflow occurs, so this branch change it to use wrapping_add()

@vbkaisetsu vbkaisetsu requested a review from odashi September 12, 2023 15:10
@vbkaisetsu vbkaisetsu marked this pull request as ready for review September 12, 2023 15:10
@vbkaisetsu vbkaisetsu enabled auto-merge (squash) September 12, 2023 15:11
tests/tests.rs Show resolved Hide resolved
@vbkaisetsu vbkaisetsu requested a review from odashi September 12, 2023 21:52
@vbkaisetsu vbkaisetsu disabled auto-merge September 13, 2023 06:22
@vbkaisetsu vbkaisetsu enabled auto-merge (squash) September 13, 2023 06:22
@vbkaisetsu vbkaisetsu merged commit 4846b60 into main Sep 13, 2023
@vbkaisetsu vbkaisetsu deleted the wrapping-add branch September 13, 2023 06:38
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