refactor: update linting rules and optimize directory handling in Unix

This commit is contained in:
Tunglies
2025-11-06 10:52:14 +08:00
Unverified
parent 5a8e83cd49
commit a0f7fb7952
2 changed files with 7 additions and 3 deletions

View File

@@ -238,4 +238,7 @@ redundant_clone = "deny"
# option_if_let_else = "deny" // 过于激进,暂时不开启
needless_pass_by_ref_mut = "deny"
needless_collect = "deny"
missing_const_for_fn = "deny"
missing_const_for_fn = "deny"
iter_with_drain = "deny"
iter_on_single_items = "deny"
iter_on_empty_collections = "deny"

View File

@@ -6,6 +6,8 @@ use crate::{
use anyhow::Result;
use async_trait::async_trait;
use once_cell::sync::OnceCell;
#[cfg(unix)]
use std::iter;
use std::{fs, path::PathBuf};
use tauri::Manager;
@@ -226,8 +228,7 @@ pub fn get_encryption_key() -> Result<Vec<u8>> {
#[cfg(unix)]
pub fn ensure_mihomo_safe_dir() -> Option<PathBuf> {
["/tmp"]
.iter()
iter::once("/tmp")
.map(PathBuf::from)
.find(|path| path.exists())
.or_else(|| {