diff --git a/vulkano/src/features.rs b/vulkano/src/features.rs index 329235d42..dde2307c5 100644 --- a/vulkano/src/features.rs +++ b/vulkano/src/features.rs @@ -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)] diff --git a/vulkano/src/instance/extensions.rs b/vulkano/src/instance/extensions.rs index b0eec8f03..5f48bc3ab 100644 --- a/vulkano/src/instance/extensions.rs +++ b/vulkano/src/instance/extensions.rs @@ -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 { self.0.iter() } }