ksud: clippy happy & fmt

This commit is contained in:
ShirkNeko
2025-11-03 12:24:36 +08:00
parent c75b041c40
commit e0bce04e79
2 changed files with 31 additions and 9 deletions

View File

@@ -218,7 +218,7 @@ pub fn list_features() -> Result<()> {
for feature_name in feature_list { for feature_name in feature_list {
feature_to_modules feature_to_modules
.entry(feature_name.clone()) .entry(feature_name.clone())
.or_insert_with(Vec::new) .or_default()
.push(module_id.clone()); .push(module_id.clone());
} }
} }
@@ -244,7 +244,13 @@ pub fn list_features() -> Result<()> {
"" ""
}; };
println!("[{}] {} (ID={}){}", status, feature_id.name(), id, managed_mark); println!(
"[{}] {} (ID={}){}",
status,
feature_id.name(),
id,
managed_mark
);
println!(" {}", feature_id.description()); println!(" {}", feature_id.description());
if let Some(modules) = managed_by { if let Some(modules) = managed_by {
@@ -331,12 +337,18 @@ pub fn init_features() -> Result<()> {
// Get managed features from active modules // Get managed features from active modules
if let Ok(managed_features_map) = crate::module::get_managed_features() { if let Ok(managed_features_map) = crate::module::get_managed_features() {
if !managed_features_map.is_empty() { if !managed_features_map.is_empty() {
log::info!("Found {} modules managing features", managed_features_map.len()); log::info!(
"Found {} modules managing features",
managed_features_map.len()
);
// Force override managed features to 0 // Force override managed features to 0
for (module_id, feature_list) in managed_features_map.iter() { for (module_id, feature_list) in managed_features_map.iter() {
log::info!("Module '{}' manages {} feature(s)", module_id, feature_list.len()); log::info!(
"Module '{}' manages {} feature(s)",
module_id,
feature_list.len()
);
for feature_name in feature_list { for feature_name in feature_list {
if let Ok(feature_id) = parse_feature_id(feature_name) { if let Ok(feature_id) = parse_feature_id(feature_name) {
let feature_id_u32 = feature_id as u32; let feature_id_u32 = feature_id as u32;
@@ -357,7 +369,9 @@ pub fn init_features() -> Result<()> {
} }
} }
} else { } else {
log::warn!("Failed to get managed features from modules, continuing with normal initialization"); log::warn!(
"Failed to get managed features from modules, continuing with normal initialization"
);
} }
if features.is_empty() { if features.is_empty() {

View File

@@ -437,7 +437,11 @@ fn mark_all_modules(flag_file: &str) -> Result<()> {
/// Read module.prop from the given module path and return as a HashMap /// Read module.prop from the given module path and return as a HashMap
pub fn read_module_prop(module_path: &Path) -> Result<HashMap<String, String>> { pub fn read_module_prop(module_path: &Path) -> Result<HashMap<String, String>> {
let module_prop = module_path.join("module.prop"); let module_prop = module_path.join("module.prop");
ensure!(module_prop.exists(), "module.prop not found in {}", module_path.display()); ensure!(
module_prop.exists(),
"module.prop not found in {}",
module_path.display()
);
let content = std::fs::read(&module_prop) let content = std::fs::read(&module_prop)
.with_context(|| format!("Failed to read module.prop: {}", module_prop.display()))?; .with_context(|| format!("Failed to read module.prop: {}", module_prop.display()))?;
@@ -521,7 +525,11 @@ pub fn get_managed_features() -> Result<HashMap<String, Vec<String>>> {
let prop_map = match read_module_prop(module_path) { let prop_map = match read_module_prop(module_path) {
Ok(prop) => prop, Ok(prop) => prop,
Err(e) => { Err(e) => {
warn!("Failed to read module.prop for {}: {}", module_path.display(), e); warn!(
"Failed to read module.prop for {}: {}",
module_path.display(),
e
);
return Ok(()); return Ok(());
} }
}; };
@@ -552,4 +560,4 @@ pub fn get_managed_features() -> Result<HashMap<String, Vec<String>>> {
})?; })?;
Ok(managed_features_map) Ok(managed_features_map)
} }