Skip to content

Commit

Permalink
contains_all_in_order
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKnauth committed Dec 19, 2023
1 parent 14b7a60 commit 3e5eb2a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,17 @@ fn parse_filter(filter: &str) -> egui_file::Filter {
let name = p.file_name().unwrap_or_default().to_string_lossy();
variants
.iter()
.any(|pieces| pieces.iter().all(|piece| name.contains(piece)))
.any(|pieces| contains_all_in_order(&name, &pieces))
})
}

fn contains_all_in_order(haystack: &str, needles: &[String]) -> bool {
let mut hay: &str = haystack;
for piece in needles {
let Some((_, rst)) = hay.split_once(piece) else {
return false;
};
hay = rst;
}
true
}

0 comments on commit 3e5eb2a

Please sign in to comment.