diff options
Diffstat (limited to 'src/libcore/char.rs')
| -rw-r--r-- | src/libcore/char.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libcore/char.rs b/src/libcore/char.rs index ba9748eea71..740fa3eb19e 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -227,7 +227,7 @@ impl CharExt for char { #[inline] pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option<usize> { // Marked #[inline] to allow llvm optimizing it away - if code < MAX_ONE_B && dst.len() >= 1 { + if code < MAX_ONE_B && !dst.is_empty() { dst[0] = code as u8; Some(1) } else if code < MAX_TWO_B && dst.len() >= 2 { @@ -258,7 +258,7 @@ pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option<usize> { #[inline] pub fn encode_utf16_raw(mut ch: u32, dst: &mut [u16]) -> Option<usize> { // Marked #[inline] to allow llvm optimizing it away - if (ch & 0xFFFF) == ch && dst.len() >= 1 { + if (ch & 0xFFFF) == ch && !dst.is_empty() { // The BMP falls through (assuming non-surrogate, as it should) dst[0] = ch as u16; Some(1) |
