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

Make set of valid strings for from_str_radix() consistent with primitives #77

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

OTheDev
Copy link
Owner

@OTheDev OTheDev commented Feb 5, 2025

In this PR, we change what constitutes a valid string slice in from_str_radix(), assign_str_radix(), from_str_base(), and assign_str_base() functions so that it is consistent with the string slice expected by from_str_radix() for primitive integer types (e.g. i32::from_str_radix()).

This is a BREAKING change, as previously, among other things, leading and trailing whitespace was permitted.

Moreover, assign_str_radix() and assign_str_base() functions no longer maintain the guarantee that the original value will remain intact if a parsing error occurs. In particular, these functions no longer validate the entire string before assigning to the arbitrary precision integer's underlying buffer. A warning has been issued in their respective documentation. This is also a BREAKING change.

Finally, we make from/assign string code much more maintainable by basing all functions on a single implementation: assign_str_base().

There is no performance degradation.

@OTheDev OTheDev merged commit b43da9f into main Feb 5, 2025
11 checks passed
@OTheDev OTheDev deleted the make_from_str_radix_consistent branch February 5, 2025 08:56
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.

1 participant