Skip to content

Commit

Permalink
rewrite if let into unwrap_or
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-ha458 committed Sep 25, 2023
1 parent c27b480 commit ae70605
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ fn in_category(

// check if character description contains at least one of patterns
fn in_description(character: &char, patterns: &[&str]) -> bool {
if let Some(description) = Name::of(*character) {
let description = format!("{}", description);
return patterns.iter().any(|&s| description.contains(s));
}
false
Name::of(*character)
.map(|description| {
patterns
.iter()
.any(|&s| description.to_string().contains(s))
})
.unwrap_or(false)
}

#[cache(LruCache: LruCache::new(*UTF8_MAXIMAL_ALLOCATION))]
Expand Down

0 comments on commit ae70605

Please sign in to comment.