Fix cargo clippy warnings across the workspace
All checks were successful
dev release / build (push) Successful in 4m4s

- Derive Default for Config instead of manually mirroring each
  sub-config's Default impl
- Use std::io::Error::other instead of Error::new(ErrorKind::Other, ..)
- Drop the unused mut on the store lock in full_reindex
- Remove Store::dim, a field that was set once and never read
- Use char_indices().enumerate() instead of a hand-rolled loop counter
  in split_by_chars, and is_multiple_of() for the chunk boundary check
- Use strip_prefix instead of manual slicing in expand_home

(cherry picked from commit b740af38e17d04bd83db93bbb0585ed5744a436e)
This commit is contained in:
Breadway 2026-08-06 08:52:18 +08:00
parent 4bfcc694bd
commit 993dc4a525
4 changed files with 8 additions and 22 deletions

View file

@ -81,10 +81,9 @@ fn split_by_chars(chunk: Chunk, max_chars: usize) -> Vec<Chunk> {
let text = &chunk.text;
let mut result = Vec::new();
let mut seg_start = 0usize;
let mut count = 0usize;
for (byte_idx, _) in text.char_indices() {
if count > 0 && count % max_chars == 0 {
for (count, (byte_idx, _)) in text.char_indices().enumerate() {
if count > 0 && count.is_multiple_of(max_chars) {
result.push(Chunk {
text: text[seg_start..byte_idx].to_string(),
start: chunk.start + seg_start,
@ -92,7 +91,6 @@ fn split_by_chars(chunk: Chunk, max_chars: usize) -> Vec<Chunk> {
});
seg_start = byte_idx;
}
count += 1;
}
if seg_start < text.len() {
result.push(Chunk {

View file

@ -64,7 +64,7 @@ impl Indexer {
pub fn full_reindex(&self) {
eprintln!("breadmill: full reindex triggered");
{
let mut store = self.state.store.lock_recover();
let store = self.state.store.lock_recover();
// Clear all state
let _ = store.conn.execute_batch("DELETE FROM chunks; DELETE FROM files;");
let _ = store.index.reserve(4096);
@ -416,9 +416,9 @@ fn sha256_str(bytes: &[u8]) -> String {
}
pub fn expand_home(path: &str) -> PathBuf {
if path.starts_with("~/") {
if let Some(rest) = path.strip_prefix("~/") {
let home = std::env::var("HOME").unwrap_or_else(|_| "/tmp".into());
PathBuf::from(home).join(&path[2..])
PathBuf::from(home).join(rest)
} else {
PathBuf::from(path)
}

View file

@ -6,7 +6,6 @@ use usearch::{Index, IndexOptions, MetricKind, ScalarKind, new_index};
pub struct Store {
pub conn: Connection,
pub index: Index,
pub dim: usize,
}
// usearch::Index wraps a raw C++ pointer; access is serialized by the Mutex<Store>.
@ -87,7 +86,7 @@ impl Store {
index.reserve(4096).map_err(|e| e.to_string())?;
}
Ok(Self { conn, index, dim })
Ok(Self { conn, index })
}
// ---- file state ---------------------------------------------------------