about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/core/src/escape.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/library/core/src/escape.rs b/library/core/src/escape.rs
index c52c1fa870e..20ac3cf027f 100644
--- a/library/core/src/escape.rs
+++ b/library/core/src/escape.rs
@@ -17,7 +17,9 @@ pub(crate) fn escape_ascii_into(output: &mut [u8; 4], byte: u8) -> Range<u8> {
         b'"' => ([b'\\', b'"', 0, 0], 2),
         b'\x20'..=b'\x7e' => ([byte, 0, 0, 0], 1),
         _ => {
-            ([b'\\', b'x', HEX_DIGITS[(byte >> 4) as usize], HEX_DIGITS[(byte & 0xf) as usize]], 4)
+            let hi = HEX_DIGITS[usize::from(byte >> 4)];
+            let lo = HEX_DIGITS[usize::from(byte & 0xf)];
+            ([b'\\', b'x', hi, lo], 4)
         }
     };
     *output = data;