clippy: fix all warnings across all binaries

- &PathBuf → &Path in memory-search.rs signatures
- Redundant field name in graph.rs struct init
- Add truncate(false) to lock file open
- Derive Default for Store instead of manual impl
- slice::from_ref instead of &[x.clone()]
- rsplit_once instead of split().last()
- str::repeat instead of iter::repeat().take().collect()
- is_none_or instead of map_or(true, ...)
- strip_prefix instead of manual slicing

Zero warnings on `cargo clippy`.
This commit is contained in:
ProofOfConcept 2026-02-28 23:47:11 -05:00
parent 7ee6f9c651
commit 29d5ed47a1
5 changed files with 15 additions and 27 deletions

View file

@ -49,7 +49,7 @@ impl StoreLock {
fn acquire() -> Result<Self, String> {
let path = lock_path();
let file = fs::OpenOptions::new()
.create(true).write(true).open(&path)
.create(true).truncate(false).write(true).open(&path)
.map_err(|e| format!("open lock {}: {}", path.display(), e))?;
// Blocking exclusive lock
@ -268,7 +268,7 @@ pub struct GapRecord {
}
// The full in-memory store
#[derive(Serialize, Deserialize)]
#[derive(Default, Serialize, Deserialize)]
pub struct Store {
pub nodes: HashMap<String, Node>, // key → latest node
#[serde(skip)]
@ -279,18 +279,6 @@ pub struct Store {
pub params: Params,
}
impl Default for Store {
fn default() -> Self {
Store {
nodes: HashMap::new(),
uuid_to_key: HashMap::new(),
relations: Vec::new(),
retrieval_log: Vec::new(),
gaps: Vec::new(),
params: Params::default(),
}
}
}
impl Store {
/// Load store: try state.json cache first, rebuild from capnp logs if stale
@ -498,7 +486,7 @@ impl Store {
/// Add a relation (appends to log + updates cache)
pub fn add_relation(&mut self, rel: Relation) -> Result<(), String> {
self.append_relations(&[rel.clone()])?;
self.append_relations(std::slice::from_ref(&rel))?;
self.relations.push(rel);
Ok(())
}
@ -1036,7 +1024,7 @@ impl Store {
let mut output = String::new();
for node in &sections {
if node.key.contains('#') {
let section_id = node.key.split('#').last().unwrap_or("");
let section_id = node.key.rsplit_once('#').map_or("", |(_, s)| s);
let links: Vec<_> = self.relations.iter()
.filter(|r| r.source_key == node.key && !r.deleted