Skip to content

bigint: Create the parsing error better for nested + - #269

Merged
homu merged 2 commits into
rust-num:masterfrom
cuviper:biguint-parse-plus
Mar 8, 2017
Merged

homu merged 2 commits into
rust-num:masterfrom
cuviper:biguint-parse-plus

Conversation

@cuviper

@cuviper cuviper commented Mar 6, 2017

Copy link
Copy Markdown
Member

If a + is encountered in the middle of parsing a BigUint, this should
generate an ParseIntError::InvalidDigit. Since we can't create that
directly, we get it by trying to parse a u64 from this point, but of
course + is a perfectly valid prefix to a u64.

Now we include the previous character in the string passed to u64, so it
has proper parsing context to understand what's in error.

Fixes #268.

cuviper added 2 commits March 6, 2017 13:20
If a `+` is encountered in the middle of parsing a BigUint, this should
generate an `ParseIntError::InvalidDigit`.  Since we can't create that
directly, we get it by trying to parse a `u64` from this point, but of
course `+` is a perfectly valid prefix to a `u64`.

Now we include the previous character in the string passed to `u64`, so
it has proper parsing context to understand what's in error.

Fixes rust-num#268.
@cuviper

cuviper commented Mar 8, 2017

Copy link
Copy Markdown
Member Author

@homu r+

@homu

homu commented Mar 8, 2017

Copy link
Copy Markdown
Contributor

📌 Commit 0b6cae0 has been approved by cuviper

@homu

homu commented Mar 8, 2017

Copy link
Copy Markdown
Contributor

⚡ Test exempted - status

@homu
homu merged commit 0b6cae0 into rust-num:master Mar 8, 2017
homu added a commit that referenced this pull request Mar 8, 2017
bigint: Create the parsing error better for nested `+`

If a `+` is encountered in the middle of parsing a BigUint, this should
generate an `ParseIntError::InvalidDigit`.  Since we can't create that
directly, we get it by trying to parse a `u64` from this point, but of
course `+` is a perfectly valid prefix to a `u64`.

Now we include the previous character in the string passed to `u64`, so it
has proper parsing context to understand what's in error.

Fixes #268.
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.

BigUint::from_str_radix panics with invalid string containing "+"

2 participants