about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichal Nazarewicz <mina86@mina86.com>2023-04-30 15:40:54 +0200
committerMichal Nazarewicz <mina86@mina86.com>2023-04-30 15:40:54 +0200
commit76c99470244777da83fa4e1fef480d6d13af2a80 (patch)
tree384e64f963f4dabb9f5db19e768784c059940b7d
parent4d0f7e2f393937afac76c97d33e0d96c50160510 (diff)
downloadrust-76c99470244777da83fa4e1fef480d6d13af2a80.tar.gz
rust-76c99470244777da83fa4e1fef480d6d13af2a80.zip
a bit more usize::from
-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;