From 74edff5678ddd0599c7e0c74e4a12ae15397b6dd Mon Sep 17 00:00:00 2001 From: soul <104170577@qq.com> Date: Sat, 24 Feb 2024 17:38:05 +0800 Subject: [PATCH] refactor: use break-label to break nested loop --- src-tauri/src/structs/queue.rs | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src-tauri/src/structs/queue.rs b/src-tauri/src/structs/queue.rs index e013dad..5a6a1a2 100644 --- a/src-tauri/src/structs/queue.rs +++ b/src-tauri/src/structs/queue.rs @@ -224,38 +224,25 @@ impl Queue { Ok(mut config_json) => { for ri in result_queue { let insert_node_id = &ri.category_id; - let mut find = false; - - for project in &mut config_json.project_list { - if find { - break; - } + 'project: for project in &mut config_json.project_list { for category in &mut project.categories { - if find { - break; - } - if category.id.as_str() == insert_node_id.as_str() { for interface in &mut category.interfaces { if interface.id == ri.id { interface.name = Some(ri.title.clone()); interface.path = Some(ri.path.clone()); - - find = true; - break; + break 'project; } } - if !find { - category.interfaces.push(InterfaceShort { - id: ri.id.clone(), - name: Some(ri.title.clone()), - path: Some(ri.path.clone()) - }); - } + category.interfaces.push(InterfaceShort { + id: ri.id.clone(), + name: Some(ri.title.clone()), + path: Some(ri.path.clone()), + }); - find = true; + break 'project; } } }