Merge pull request #520 from dylanede/master

Support for taking differences of extension and feature sets
This commit is contained in:
tomaka 2017-06-12 22:28:39 +02:00 committed by GitHub
commit 1c44b5b13b
2 changed files with 27 additions and 0 deletions

View File

@ -89,6 +89,17 @@ macro_rules! features {
)+
}
}
/// Builds a `Features` that is the difference of another `Features` object from `self`.
///
/// The result's field will be true if it is true in `self` but not `other`.
pub fn difference(&self, other: &Features) -> Features {
Features {
$(
$name: self.$name && !other.$name,
)+
}
}
}
#[doc(hidden)]

View File

@ -61,6 +61,17 @@ macro_rules! extensions {
_unbuildable: Unbuildable(())
}
}
/// Returns the difference of another list from this list.
#[inline]
pub fn difference(&self, other: &$sname) -> $sname {
$sname {
$(
$ext: self.$ext && !other.$ext,
)*
_unbuildable: Unbuildable(())
}
}
}
impl fmt::Debug for $sname {
@ -110,6 +121,11 @@ macro_rules! extensions {
$rawname(self.0.intersection(&other.0).cloned().collect())
}
/// Returns the difference of another set from this one.
pub fn difference(&self, other: &Self) -> Self {
$rawname(self.0.difference(&other.0).cloned().collect())
}
// TODO: impl Iterator
pub fn iter(&self) -> ::std::collections::hash_set::Iter<CString> { self.0.iter() }
}