fix(app-iced): 测试助手改用 matches!,消掉 deny 级 clippy(复审 r2 P1-1)

`dispatched_adopt` 内层 `match (&**command, want) { … _ => false }` 被判
`match expression looks like matches! macro`(deny 级 ⟹ CI 的 `--workspace --all-targets
-D warnings` 必红;558fbf2 原树 `cargo clippy -p unlucky-app-iced --all-targets` 实测 exit 101)。

改成 `let AppCommand::Adopt(..) = command else { return false }` + 一条 `matches!`,
判据与原来逐字等价(四种命令种类 × 对应 slug)。同一处的注释补一句「为什么不能再写 match」,
免得下一个人改回去。

教训记账:r2 自验只跑了 fmt/check/test,漏了 clippy(T23「五步少一步等于那步不存在」);
本轮五步齐跑,退出码见完成报告。
This commit is contained in:
AskaEth committed 2026-11-10 19:37:45 +08:00
1 parent fa3fab9086
commit 44c00b4873
1 file changed
+14 -9
+14 -9
View File
@@ -199,16 +199,21 @@ mod tests {
}
/// 台账里有没有派过某条 adopt 命令(只认命令种类,不看载荷内容)。
///
/// 写法是 `let ... else` + `matches!`:内层用 `match` 会被 clippy 判成
/// `match expression looks like matches! macro`(deny 级,CI 的 `-D warnings` 直接红)。
fn dispatched_adopt(ledger: &Rc<RefCell<Vec<AppCommand>>>, want: &str) -> bool {
ledger.borrow().iter().any(|command| match command {
AppCommand::Adopt(command) => match (&**command, want) {
(AdoptCommand::Scan, "scan") => true,
(AdoptCommand::Preview(_), "preview") => true,
(AdoptCommand::Confirm(_), "confirm") => true,
(AdoptCommand::Dismiss, "dismiss") => true,
_ => false,
},
_ => false,
ledger.borrow().iter().any(|command| {
let AppCommand::Adopt(command) = command else {
return false;
};
matches!(
(&**command, want),
(AdoptCommand::Scan, "scan")
| (AdoptCommand::Preview(_), "preview")
| (AdoptCommand::Confirm(_), "confirm")
| (AdoptCommand::Dismiss, "dismiss")
)
})
}