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

Skip error codepath on hex escape outside the surrogate range #831

Merged
merged 1 commit into from
Nov 25, 2021

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Nov 25, 2021

For n: u16 where 0xD800..=0xDBFF and 0xDC00..=0xDFFF have already been handled, the conversion char::from_u32(n as u32) can't fail.

for n in 0..=u16::MAX as u32 {
    let expected_is_okay = n < 0xd800 || n > 0xdfff;
    let actual_is_okay = char::from_u32(n).is_some();
    assert_eq!(expected_is_okay, actual_is_okay);
}

@dtolnay dtolnay merged commit fc0ca07 into master Nov 25, 2021
@dtolnay dtolnay deleted the from_u32 branch November 25, 2021 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant