mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-04-24 17:12:16 +02:00
Use new Match::or to simplify return
This commit is contained in:
parent
1aeae3e22d
commit
a05671c8d7
@ -360,19 +360,8 @@ impl Ignore {
|
|||||||
}
|
}
|
||||||
let m_global = self.0.git_global_matcher.matched(&path, is_dir)
|
let m_global = self.0.git_global_matcher.matched(&path, is_dir)
|
||||||
.map(IgnoreMatch::gitignore);
|
.map(IgnoreMatch::gitignore);
|
||||||
if !m_ignore.is_none() {
|
|
||||||
m_ignore
|
m_ignore.or(m_gi).or(m_gi_exclude).or(m_global).or(m_explicit)
|
||||||
} else if !m_gi.is_none() {
|
|
||||||
m_gi
|
|
||||||
} else if !m_gi_exclude.is_none() {
|
|
||||||
m_gi_exclude
|
|
||||||
} else if !m_global.is_none() {
|
|
||||||
m_global
|
|
||||||
} else if !m_explicit.is_none() {
|
|
||||||
m_explicit
|
|
||||||
} else {
|
|
||||||
Match::None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over parent ignore matchers, including this one.
|
/// Returns an iterator over parent ignore matchers, including this one.
|
||||||
|
@ -297,4 +297,13 @@ impl<T> Match<T> {
|
|||||||
Match::Whitelist(t) => Match::Whitelist(f(t)),
|
Match::Whitelist(t) => Match::Whitelist(f(t)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the match if it is not none. Otherwise, return other.
|
||||||
|
pub fn or(self, other: Self) -> Self {
|
||||||
|
if self.is_none() {
|
||||||
|
other
|
||||||
|
} else {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user