style(context): bersihkan warning clippy pedantic di squash.rs dan dedup.rs

Perbaikan gaya murni (format! di-append ke String -> write!, syntax
perbandingan yang lebih jelas, backtick di doc comment) tanpa
mengubah perilaku -- semua test tetap hijau.
This commit is contained in:
asepharyana
2026-07-16 07:56:11 +07:00
parent d6de9735ab
commit e075eb7acc
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -12,6 +12,7 @@
//! overall budget.
use std::collections::HashSet;
use std::fmt::Write;
/// Below this size, compression isn't worth the risk of losing detail —
/// pass the output through unchanged.
@@ -249,7 +250,7 @@ fn squash_generic(text: &str, budget: usize) -> String {
let mut prev = "";
for (i, &line) in lines.iter().enumerate().take(tail_start).skip(head_end) {
let non_trivial = !line.trim().is_empty() && line != prev;
if non_trivial && used + line.len() + 1 <= budget {
if non_trivial && used + line.len() < budget {
keep.insert(i);
used += line.len() + 1;
}
@@ -269,14 +270,14 @@ fn render_kept_lines(lines: &[&str], keep: &HashSet<usize>) -> String {
let mut cursor = 0usize;
for &i in &kept_sorted {
if i > cursor {
out.push_str(&format!("[{} lines omitted]\n", i - cursor));
let _ = writeln!(out, "[{} lines omitted]", i - cursor);
}
out.push_str(lines[i]);
out.push('\n');
cursor = i + 1;
}
if cursor < lines.len() {
out.push_str(&format!("[{} lines omitted]\n", lines.len() - cursor));
let _ = writeln!(out, "[{} lines omitted]", lines.len() - cursor);
}
out
}