Use StringMatchCandidate::new to construct candidates more conveniently

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-01-31 19:11:13 +01:00
parent 1e96fc98e7
commit bd2527e691
4 changed files with 25 additions and 19 deletions

View file

@ -98,6 +98,16 @@ impl<'a> MatchCandidate for PathMatchCandidate<'a> {
}
}
impl StringMatchCandidate {
pub fn new(id: usize, string: String) -> Self {
Self {
id,
char_bag: CharBag::from(string.as_str()),
string,
}
}
}
impl<'a> MatchCandidate for &'a StringMatchCandidate {
fn has_chars(&self, bag: CharBag) -> bool {
self.char_bag.is_superset(bag)