Skip to content

Commit c0dc2a4

Browse files
lpcoxCopilot
andauthored
Update guards/github-guard/rust-guard/src/lib.rs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 41cdf83 commit c0dc2a4

File tree

1 file changed

+5
-1
lines changed
  • guards/github-guard/rust-guard/src

1 file changed

+5
-1
lines changed

guards/github-guard/rust-guard/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ fn safe_preview(s: &str, max_bytes: usize) -> &str {
3535
if s.len() <= max_bytes {
3636
return s;
3737
}
38-
let end = s.floor_char_boundary(max_bytes);
38+
39+
let mut end = max_bytes;
40+
while end > 0 && !s.is_char_boundary(end) {
41+
end -= 1;
42+
}
3943
&s[..end]
4044
}
4145

0 commit comments

Comments
 (0)