File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -795,14 +795,14 @@ fn limit_string(string: &str, max_size: usize) -> &str {
795795 if string. len ( ) <= max_size {
796796 return string;
797797 }
798- let p = string. as_ptr ( ) ;
798+ let p = string. as_bytes ( ) ;
799799 let mut index = max_size;
800800 // We want to clip the string at [max_size]; however, the character at that position
801801 // may span several bytes. We need to find the first byte of the character. In UTF-8
802802 // encoded data any byte that matches the bit pattern 10XXXXXX is not a start byte.
803803 // Therefore we decrement the index as long as there are bytes matching this pattern.
804804 // This ensures we cut the string at the border between one character and another.
805- while index > 0 && unsafe { ( * p . add ( index) & 0b11000000 ) == 0b10000000 } {
805+ while index > 0 && ( p [ index] & 0b11000000 ) == 0b10000000 {
806806 index -= 1 ;
807807 }
808808 & string[ 0 ..index]
You can’t perform that action at this time.
0 commit comments