fix: resolve unused assignment warning in material_matching_service
- Changed termination_reason from String to Option<String> to eliminate unused assignment warning - Updated all assignments to use Some() wrapper - Simplified default value logic using unwrap_or_else() - Maintains same functionality while making code more idiomatic Rust
This commit is contained in:
parent
6bd12a4a63
commit
ff31a48256
|
|
@ -755,7 +755,7 @@ impl MaterialMatchingService {
|
||||||
let mut total_rounds = 0u32;
|
let mut total_rounds = 0u32;
|
||||||
let mut successful_rounds = 0u32;
|
let mut successful_rounds = 0u32;
|
||||||
let mut global_used_segment_ids = HashSet::new();
|
let mut global_used_segment_ids = HashSet::new();
|
||||||
let mut termination_reason = String::new();
|
let mut termination_reason: Option<String> = None;
|
||||||
let mut materials_exhausted = false;
|
let mut materials_exhausted = false;
|
||||||
|
|
||||||
// 为每个模板维护独立的序号计数器
|
// 为每个模板维护独立的序号计数器
|
||||||
|
|
@ -805,7 +805,7 @@ impl MaterialMatchingService {
|
||||||
|
|
||||||
// 如果没有任何模板可以匹配,提前终止
|
// 如果没有任何模板可以匹配,提前终止
|
||||||
if !any_template_can_match {
|
if !any_template_can_match {
|
||||||
termination_reason = format!("第{}轮预检查发现无任何模板可完整匹配,提前终止", total_rounds);
|
termination_reason = Some(format!("第{}轮预检查发现无任何模板可完整匹配,提前终止", total_rounds));
|
||||||
materials_exhausted = true;
|
materials_exhausted = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -916,7 +916,7 @@ impl MaterialMatchingService {
|
||||||
// 检查是否应该继续下一轮
|
// 检查是否应该继续下一轮
|
||||||
if round_successful_matches == 0 {
|
if round_successful_matches == 0 {
|
||||||
// 本轮没有任何成功匹配,终止循环
|
// 本轮没有任何成功匹配,终止循环
|
||||||
termination_reason = format!("第{}轮无任何成功匹配,素材已耗尽", total_rounds);
|
termination_reason = Some(format!("第{}轮无任何成功匹配,素材已耗尽", total_rounds));
|
||||||
materials_exhausted = true;
|
materials_exhausted = true;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -925,15 +925,13 @@ impl MaterialMatchingService {
|
||||||
|
|
||||||
// 可选:添加最大轮数限制,防止无限循环
|
// 可选:添加最大轮数限制,防止无限循环
|
||||||
if total_rounds >= 100 {
|
if total_rounds >= 100 {
|
||||||
termination_reason = "达到最大轮数限制(100轮)".to_string();
|
termination_reason = Some("达到最大轮数限制(100轮)".to_string());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置默认终止原因(如果没有设置)
|
// 设置默认终止原因(如果没有设置)
|
||||||
if termination_reason.is_empty() {
|
let final_termination_reason = termination_reason.unwrap_or_else(|| "正常完成".to_string());
|
||||||
termination_reason = "正常完成".to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计算汇总信息
|
// 计算汇总信息
|
||||||
let summary = self.calculate_batch_summary(&matching_results);
|
let summary = self.calculate_batch_summary(&matching_results);
|
||||||
|
|
@ -949,7 +947,7 @@ impl MaterialMatchingService {
|
||||||
summary,
|
summary,
|
||||||
total_rounds,
|
total_rounds,
|
||||||
successful_rounds,
|
successful_rounds,
|
||||||
termination_reason,
|
termination_reason: final_termination_reason,
|
||||||
materials_exhausted,
|
materials_exhausted,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue