Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/cfg/src/lib.rs')
| -rw-r--r-- | crates/cfg/src/lib.rs | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/crates/cfg/src/lib.rs b/crates/cfg/src/lib.rs index 417ba60919..f867a903b0 100644 --- a/crates/cfg/src/lib.rs +++ b/crates/cfg/src/lib.rs @@ -66,24 +66,21 @@ impl CfgOptions { } } - pub fn get_cfg_keys(&self) -> Vec<&SmolStr> { - self.enabled - .iter() - .map(|x| match x { - CfgAtom::Flag(key) => key, - CfgAtom::KeyValue { key, .. } => key, - }) - .collect() + pub fn get_cfg_keys(&self) -> impl Iterator<Item = &SmolStr> { + self.enabled.iter().map(|x| match x { + CfgAtom::Flag(key) => key, + CfgAtom::KeyValue { key, .. } => key, + }) } - pub fn get_cfg_values(&self, cfg_key: &str) -> Vec<&SmolStr> { - self.enabled - .iter() - .filter_map(|x| match x { - CfgAtom::KeyValue { key, value } if cfg_key == key => Some(value), - _ => None, - }) - .collect() + pub fn get_cfg_values<'a>( + &'a self, + cfg_key: &'a str, + ) -> impl Iterator<Item = &'a SmolStr> + 'a { + self.enabled.iter().filter_map(move |x| match x { + CfgAtom::KeyValue { key, value } if cfg_key == key => Some(value), + _ => None, + }) } } |