From 775b3792cd526e51c3436bbd242595bc81ee216d Mon Sep 17 00:00:00 2001 From: Suzumiya Date: Fri, 11 Sep 2026 12:21:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=20rustfmt=EF=BC=9Aresource=5Feditor?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9E=E7=94=A8=E4=BE=8B=E6=8C=89=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E6=A0=BC=E5=BC=8F=E6=8A=98=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `editor_api_rejection_reason_from_body` 用例里 3 处 `serde_json::json!(...).to_string().as_str()` 实参按 rustfmt 口径断行 - `editor_api_rejection_reason_from_body("502")` 断言折行 - 连带收掉 `remote-terminal-failed` 的 match 分支:该 arm 因上一提交改宽而超行宽,按 rustfmt 折成块 - `resource_editor.rs` 现在通过 `cargo fmt --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml -- --check` --- .../src-tauri/src/project/resource_editor.rs | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/project/resource_editor.rs b/apps/ai-game-creator-shell/src-tauri/src/project/resource_editor.rs index b9162ae31..160026329 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/project/resource_editor.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/project/resource_editor.rs @@ -2597,7 +2597,9 @@ async fn submit_resource_edit_remote( return Err(error.clone()); } return Err(match editor_api_rejection_reason(response).await { - Some(reason) => format!("remote-terminal-failed: 资源编辑请求被拒绝:HTTP 400({reason})"), + Some(reason) => { + format!("remote-terminal-failed: 资源编辑请求被拒绝:HTTP 400({reason})") + } None => "remote-terminal-failed: 资源编辑请求被拒绝:HTTP 400".to_string(), }); } @@ -5568,12 +5570,18 @@ mod tests { "BAD_REQUEST 不重复透出错误码" ); assert_eq!( - editor_api_rejection_reason_from_body(serde_json::json!({ "error": "直白文本" }).to_string().as_str()), + editor_api_rejection_reason_from_body( + serde_json::json!({ "error": "直白文本" }) + .to_string() + .as_str() + ), Some("直白文本".to_string()) ); assert_eq!( editor_api_rejection_reason_from_body( - serde_json::json!({ "message": "顶层文案" }).to_string().as_str() + serde_json::json!({ "message": "顶层文案" }) + .to_string() + .as_str() ), Some("顶层文案".to_string()) ); @@ -5581,11 +5589,16 @@ mod tests { // 空值与非 JSON 正文不给用户编造原因。 assert_eq!( editor_api_rejection_reason_from_body( - serde_json::json!({ "error": { "message": " " } }).to_string().as_str() + serde_json::json!({ "error": { "message": " " } }) + .to_string() + .as_str() ), None ); - assert_eq!(editor_api_rejection_reason_from_body("502"), None); + assert_eq!( + editor_api_rejection_reason_from_body("502"), + None + ); assert_eq!(editor_api_rejection_reason_from_body(""), None); // 超长正文仍按 200 字符截断,避免把整段响应体塞进用户可见文案。