Skip to content

Commit 2a32b59

Browse files
authored
Merge pull request #331 from github/aibaars/remove-unsafe
Remove use of 'unsafe'
2 parents 1c08592 + 439d873 commit 2a32b59

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

extractor/src/extractor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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]

0 commit comments

Comments
 (0)