mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 19:17:43 +00:00
manual_range_contains
This commit is contained in:
parent
d7e1f1cc08
commit
c15adf6557
@ -207,7 +207,7 @@ fn write_valid_utf8_to_console(handle: c::HANDLE, utf8: &str) -> io::Result<usiz
|
|||||||
// write the missing surrogate out now.
|
// write the missing surrogate out now.
|
||||||
// Buffering it would mean we have to lie about the number of bytes written.
|
// Buffering it would mean we have to lie about the number of bytes written.
|
||||||
let first_code_unit_remaining = utf16[written];
|
let first_code_unit_remaining = utf16[written];
|
||||||
if first_code_unit_remaining >= 0xDCEE && first_code_unit_remaining <= 0xDFFF {
|
if matches!(first_code_unit_remaining, 0xDCEE..=0xDFFF) {
|
||||||
// low surrogate
|
// low surrogate
|
||||||
// We just hope this works, and give up otherwise
|
// We just hope this works, and give up otherwise
|
||||||
let _ = write_u16s(handle, &utf16[written..written + 1]);
|
let _ = write_u16s(handle, &utf16[written..written + 1]);
|
||||||
@ -332,7 +332,7 @@ fn read_u16s_fixup_surrogates(
|
|||||||
// and it is not 0, so we know that `buf[amount - 1]` have been
|
// and it is not 0, so we know that `buf[amount - 1]` have been
|
||||||
// initialized.
|
// initialized.
|
||||||
let last_char = unsafe { buf[amount - 1].assume_init() };
|
let last_char = unsafe { buf[amount - 1].assume_init() };
|
||||||
if last_char >= 0xD800 && last_char <= 0xDBFF {
|
if matches!(last_char, 0xD800..=0xDBFF) {
|
||||||
// high surrogate
|
// high surrogate
|
||||||
*surrogate = last_char;
|
*surrogate = last_char;
|
||||||
amount -= 1;
|
amount -= 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user