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:
parent
7ee6f9c651
commit
29d5ed47a1
5 changed files with 15 additions and 27 deletions
|
|
@ -10,7 +10,7 @@
|
|||
use std::collections::HashSet;
|
||||
use std::fs;
|
||||
use std::io::{self, Read, Write};
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
|
|
@ -138,7 +138,7 @@ fn extract_key_from_line(line: &str) -> Option<String> {
|
|||
}
|
||||
}
|
||||
|
||||
fn load_or_create_cookie(dir: &PathBuf, session_id: &str) -> String {
|
||||
fn load_or_create_cookie(dir: &Path, session_id: &str) -> String {
|
||||
let path = dir.join(format!("cookie-{}", session_id));
|
||||
if path.exists() {
|
||||
fs::read_to_string(&path).unwrap_or_default().trim().to_string()
|
||||
|
|
@ -165,7 +165,7 @@ fn generate_cookie() -> String {
|
|||
.collect()
|
||||
}
|
||||
|
||||
fn load_seen(dir: &PathBuf, session_id: &str) -> HashSet<String> {
|
||||
fn load_seen(dir: &Path, session_id: &str) -> HashSet<String> {
|
||||
let path = dir.join(format!("seen-{}", session_id));
|
||||
if path.exists() {
|
||||
fs::read_to_string(path)
|
||||
|
|
@ -178,7 +178,7 @@ fn load_seen(dir: &PathBuf, session_id: &str) -> HashSet<String> {
|
|||
}
|
||||
}
|
||||
|
||||
fn mark_seen(dir: &PathBuf, session_id: &str, key: &str) {
|
||||
fn mark_seen(dir: &Path, session_id: &str, key: &str) {
|
||||
let path = dir.join(format!("seen-{}", session_id));
|
||||
if let Ok(mut f) = fs::OpenOptions::new().create(true).append(true).open(path) {
|
||||
writeln!(f, "{}", key).ok();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue