Skip to content

Commit

Permalink
refactor: use iter().any to search vector
Browse files Browse the repository at this point in the history
  • Loading branch information
soul committed Feb 24, 2024
1 parent 3e0befb commit 3cf5b86
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src-tauri/src/services/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,10 @@ fn merge_projects(new_project: &ProjectShort, old_config: &mut ConfigJson) {

fn merge_categories(new_project: &ProjectShort, old_project: &mut ProjectShort) {
for category in &new_project.categories {
let mut find = false;
for old_category in &old_project.categories {
if find == true {
break;
}
if old_category.id == category.id {
find = true;
}
}

if find == false {
old_project.categories.push(category.clone());
if old_project.categories.iter().any(|oc| oc.id == category.id) {
continue;
}
old_project.categories.push(category.clone());
}
}

0 comments on commit 3cf5b86

Please sign in to comment.