We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 67a02b2 commit ca607f5Copy full SHA for ca607f5
src/repr/src/adt/char.rs
@@ -141,6 +141,12 @@ fn format_char_str(
141
// does.
142
Some(l) => {
143
let l = usize::cast_from(l.into_u32());
144
+ // The number of chars in a string is always less or equal to the length of the string.
145
+ // Hence, if the string is shorter than the length, we do not have to check for
146
+ // the maximum length.
147
+ if s.len() < l {
148
+ return Ok(white_space.process_str(s, Some(l)));
149
+ }
150
match s.char_indices().nth(l) {
151
None => white_space.process_str(s, Some(l)),
152
Some((idx, _)) => {
0 commit comments