Added arithmetic safety and unit tests to Plotters Backend#738
Open
RPG-Alex wants to merge 25 commits intoplotters-rs:masterfrom
Open
Added arithmetic safety and unit tests to Plotters Backend#738RPG-Alex wants to merge 25 commits intoplotters-rs:masterfrom
RPG-Alex wants to merge 25 commits intoplotters-rs:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I started looking at what needed to be done to rectify issue #709 , and realized this bug was possible in pretty much every part of the crate, as there is a lot of unchecked math happening.
In the
plotters_backendmodule, I have addedmath_guard, andmath_error, for trying to simplify the most common arithmetic operations. I also cleaned up the errors for the backend, as there were 2 enums and 1 struct with the same name, so abstracted all to a single error enum and converted instances of the struct version to the correct enum.Before applying the
math_guardto the whole crate I wanted to see if the shape and implementation would be acceptable.I also added unit tests to all modules, to help make sure I wasn't breaking anything with the refactor.
Right now the backend should be in a position where it will handle errors around unsafe math rather than panicking. If this looks acceptable please merge the PR and let me know so I can continue with the refactor for the rest of the crate to use
math_guard.