More consistent names in flags API

Improves consistency with other newtypes and with bitflags.
This commit is contained in:
Benjamin Saunders 2018-09-16 11:59:55 -07:00
parent f13e01d026
commit 0446b59873
3 changed files with 1885 additions and 1992 deletions

File diff suppressed because it is too large Load diff

View file

@ -333,7 +333,7 @@ impl ExampleBase {
.enumerate()
.filter_map(|(index, ref info)| {
let supports_graphic_and_surface =
info.queue_flags.subset(vk::QueueFlags::GRAPHICS) && surface_loader
info.queue_flags.contains(vk::QueueFlags::GRAPHICS) && surface_loader
.get_physical_device_surface_support_khr(
*pdevice,
index as u32,
@ -410,7 +410,7 @@ impl ExampleBase {
};
let pre_transform = if surface_capabilities
.supported_transforms
.subset(vk::SurfaceTransformFlagsKHR::IDENTITY)
.contains(vk::SurfaceTransformFlagsKHR::IDENTITY)
{
vk::SurfaceTransformFlagsKHR::IDENTITY
} else {

View file

@ -210,23 +210,10 @@ pub fn vk_bitflags_wrapped_macro() -> Tokens {
}
#[inline]
pub fn flags(self) -> $flag_type {
self.0
}
pub fn from_raw(x: $flag_type) -> Self { $name(x) }
#[inline]
pub fn from_flags(flags: $flag_type) -> Option<$name> {
if flags & !$all == 0 {
Some($name(flags))
} else {
None
}
}
#[inline]
pub fn from_flags_truncate(flags: $flag_type) -> $name {
$name (flags & $all)
}
pub fn as_raw(self) -> $flag_type { self.0 }
#[inline]
pub fn is_empty(self) -> bool {
@ -243,9 +230,9 @@ pub fn vk_bitflags_wrapped_macro() -> Tokens {
self & other != $name::empty()
}
/// Returns true of `other` is a subset of `self`
/// Returns whether `other` is a subset of `self`
#[inline]
pub fn subset(self, other: $name) -> bool {
pub fn contains(self, other: $name) -> bool {
self & other == other
}
}