File tree 1 file changed +6
-9
lines changed
1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -1736,14 +1736,11 @@ impl EscapeDebugExtArgs {
1736
1736
1737
1737
#[ inline]
1738
1738
const fn len_utf8 ( code : u32 ) -> usize {
1739
- if code < MAX_ONE_B {
1740
- 1
1741
- } else if code < MAX_TWO_B {
1742
- 2
1743
- } else if code < MAX_THREE_B {
1744
- 3
1745
- } else {
1746
- 4
1739
+ match code {
1740
+ ..MAX_ONE_B => 1 ,
1741
+ ..MAX_TWO_B => 2 ,
1742
+ ..MAX_THREE_B => 3 ,
1743
+ _ => 4
1747
1744
}
1748
1745
}
1749
1746
@@ -1785,7 +1782,7 @@ pub const fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> &mut [u8] {
1785
1782
* c = ( code >> 6 & 0x3F ) as u8 | TAG_CONT ;
1786
1783
* d = ( code & 0x3F ) as u8 | TAG_CONT ;
1787
1784
}
1788
- // Note that the original message is not const-compatible due to formatting .
1785
+ // Note that we cannot format in constant expressions .
1789
1786
_ => panic ! ( "encode_utf8: buffer does not have enough bytes to encode code point" ) ,
1790
1787
} ;
1791
1788
// SAFETY: `<&mut [u8]>::as_mut_ptr` is guaranteed to return a valid pointer and `len` has been tested to be within bounds.
You can’t perform that action at this time.
0 commit comments