fix(core): silence three clippy warnings blocking CI gate

* line_index.rs: replace manual `x % BLOCK_SIZE == 0` with
  `.is_multiple_of(BLOCK_SIZE)` (Rust 1.81+).

* line_index.rs: gate three pub(crate) accessor methods
  (`sampled_offsets`, `total_lines`, `has_trailing_newline`) behind
  `#[cfg(test)]`. They are only consumed by tests in file_reader.rs;
  marking them test-only removes them from production builds entirely,
  eliminating the dead_code warning without suppressing it.

* json.rs: drop redundant `Some(... .ok()?)` wrapper in
  parse_json_object_with_duplicates. `.ok()` already returns Option,
  so wrapping it in Some and unwrapping with ? was a no-op.

No behavior change. Unblocks `cargo clippy --workspace -- -D warnings`.
This commit is contained in:
dailz
2026-06-22 15:02:33 +08:00
parent e69b7af32a
commit 95f259a2bb
2 changed files with 20 additions and 8 deletions
+4 -2
View File
@@ -158,7 +158,7 @@ impl LineIndex {
// If the junction falls on a block boundary, record the start offset
// (analogous to from_bytes always pushing offset 0 for line 0).
if starts_new_line && (old_total as usize) % BLOCK_SIZE == 0 {
if starts_new_line && (old_total as usize).is_multiple_of(BLOCK_SIZE) {
self.sampled_offsets.push(start_offset);
}
@@ -212,15 +212,17 @@ impl LineIndex {
self.total_lines as usize
}
// ─── getter 方法 ────────────────────────────────────────────────────
#[cfg(test)]
pub(crate) fn sampled_offsets(&self) -> &[u64] {
&self.sampled_offsets
}
#[cfg(test)]
pub(crate) fn total_lines(&self) -> u64 {
self.total_lines
}
#[cfg(test)]
pub(crate) fn has_trailing_newline(&self) -> bool {
self.has_trailing_newline
}