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 {
795
795
if string. len ( ) <= max_size {
796
796
return string;
797
797
}
798
- let p = string. as_ptr ( ) ;
798
+ let p = string. as_bytes ( ) ;
799
799
let mut index = max_size;
800
800
// We want to clip the string at [max_size]; however, the character at that position
801
801
// may span several bytes. We need to find the first byte of the character. In UTF-8
802
802
// encoded data any byte that matches the bit pattern 10XXXXXX is not a start byte.
803
803
// Therefore we decrement the index as long as there are bytes matching this pattern.
804
804
// 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 {
806
806
index -= 1 ;
807
807
}
808
808
& string[ 0 ..index]
You can’t perform that action at this time.
0 commit comments