src/config/matchable.rs
raw| 1 | use super::ident::Ident; |
| 2 | |
| 3 | pub trait Matchable { |
| 4 | type Item; |
| 5 | |
| 6 | fn matched(&self, name: &str) -> Vec<&Self::Item>; |
| 7 | } |
| 8 | |
| 9 | impl<T: AsRef<Ident>> Matchable for [T] { |
| 10 | type Item = T; |
| 11 | |
| 12 | fn matched(&self, name: &str) -> Vec<&Self::Item> { |
| 13 | self.iter() |
| 14 | .filter(|item| item.as_ref().is_match(name)) |
| 15 | .collect() |
| 16 | } |
| 17 | } |