FeatureSetFns
Populates only the feature bits specified.
Functions
- featureSet
- Populates only the feature bits specified.
- featureSetHas
- Returns true if the specified feature is enabled.
- featureSetHasAny
- Returns true if any specified feature is enabled.
- featureSetHasAll
- Returns true if every specified feature is enabled.
Source
Implementation
pub fn FeatureSetFns(comptime F: type) type {
return struct {
/// Populates only the feature bits specified.
pub fn featureSet(features: []const F) Set {
var x = Set.empty;
for (features) |feature| {
x.addFeature(@intFromEnum(feature));
}
return x;
}
/// Returns true if the specified feature is enabled.
pub fn featureSetHas(set: Set, feature: F) bool {
return set.isEnabled(@intFromEnum(feature));
}
/// Returns true if any specified feature is enabled.
pub fn featureSetHasAny(set: Set, features: anytype) bool {
inline for (features) |feature| {
if (set.isEnabled(@intFromEnum(@as(F, feature)))) return true;
}
return false;
}
/// Returns true if every specified feature is enabled.
pub fn featureSetHasAll(set: Set, features: anytype) bool {
inline for (features) |feature| {
if (!set.isEnabled(@intFromEnum(@as(F, feature)))) return false;
}
return true;
}
};
}