Fix cfg completions not working

This commit is contained in:
Lukas Wirth 2023-08-29 10:57:24 +02:00
parent ca6ddd8ea3
commit 853f8a21f7
4 changed files with 98 additions and 33 deletions

View file

@ -86,6 +86,32 @@ impl CfgOptions {
}
}
impl Extend<CfgAtom> for CfgOptions {
fn extend<T: IntoIterator<Item = CfgAtom>>(&mut self, iter: T) {
iter.into_iter().for_each(|cfg_flag| _ = self.enabled.insert(cfg_flag));
}
}
impl IntoIterator for CfgOptions {
type Item = <FxHashSet<CfgAtom> as IntoIterator>::Item;
type IntoIter = <FxHashSet<CfgAtom> as IntoIterator>::IntoIter;
fn into_iter(self) -> Self::IntoIter {
<FxHashSet<CfgAtom> as IntoIterator>::into_iter(self.enabled)
}
}
impl<'a> IntoIterator for &'a CfgOptions {
type Item = <&'a FxHashSet<CfgAtom> as IntoIterator>::Item;
type IntoIter = <&'a FxHashSet<CfgAtom> as IntoIterator>::IntoIter;
fn into_iter(self) -> Self::IntoIter {
<&FxHashSet<CfgAtom> as IntoIterator>::into_iter(&self.enabled)
}
}
#[derive(Default, Clone, Debug, PartialEq, Eq)]
pub struct CfgDiff {
// Invariants: No duplicates, no atom that's both in `enable` and `disable`.