mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-18 14:21:32 +03:00
refactor: replace map_or(false, ...)
with is_some_and(...)
This commit is contained in:
parent
73b9c62944
commit
e5340a2beb
@ -25,8 +25,8 @@ impl Open {
|
||||
{
|
||||
self.rules.iter().find_map(|rule| {
|
||||
let is_folder = Some(mime.as_ref() == MIME_DIR);
|
||||
if rule.mime.as_ref().map_or(false, |m| m.matches(&mime))
|
||||
|| rule.name.as_ref().map_or(false, |n| n.match_path(&path, is_folder))
|
||||
if rule.mime.as_ref().is_some_and(|m| m.matches(&mime))
|
||||
|| rule.name.as_ref().is_some_and(|n| n.match_path(&path, is_folder))
|
||||
{
|
||||
let openers = rule
|
||||
.use_
|
||||
|
@ -30,7 +30,7 @@ impl Pattern {
|
||||
} else {
|
||||
path.file_name().and_then(|n| n.to_str()).or_else(|| path.to_str())
|
||||
};
|
||||
is_folder.map_or(true, |f| f == self.is_folder) && s.map_or(false, |s| self.matches(s))
|
||||
is_folder.map_or(true, |f| f == self.is_folder) && s.is_some_and(|s| self.matches(s))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,11 +13,11 @@ pub struct Filetype {
|
||||
|
||||
impl Filetype {
|
||||
pub fn matches(&self, path: &Path, mime: Option<impl AsRef<str>>, is_dir: bool) -> bool {
|
||||
if self.name.as_ref().map_or(false, |e| e.match_path(path, Some(is_dir))) {
|
||||
if self.name.as_ref().is_some_and(|e| e.match_path(path, Some(is_dir))) {
|
||||
return true;
|
||||
}
|
||||
if let Some(mime) = mime {
|
||||
return self.mime.as_ref().map_or(false, |m| m.matches(mime));
|
||||
return self.mime.as_ref().is_some_and(|m| m.matches(mime));
|
||||
}
|
||||
false
|
||||
}
|
||||
|
@ -367,8 +367,8 @@ impl Manager {
|
||||
false
|
||||
};
|
||||
|
||||
b |= self.active_mut().parent.as_mut().map_or(false, |p| p.hover(&cwd));
|
||||
b |= hovered.as_ref().map_or(false, |h| self.current_mut().hover(h));
|
||||
b |= self.active_mut().parent.as_mut().is_some_and(|p| p.hover(&cwd));
|
||||
b |= hovered.as_ref().is_some_and(|h| self.current_mut().hover(h));
|
||||
|
||||
if hovered.as_ref() != self.hovered().map(|h| h.url()) {
|
||||
emit!(Hover);
|
||||
|
Loading…
Reference in New Issue
Block a user