Make handle and bitflags constructors functions const

Fixes #187
This commit is contained in:
Aaron Loucks 2019-05-25 16:00:15 -04:00
parent 19771a8200
commit fb982fe419
2 changed files with 12 additions and 12 deletions

View file

@ -85,19 +85,19 @@ macro_rules! vk_bitflags_wrapped {
} }
impl $name { impl $name {
#[inline] #[inline]
pub fn empty() -> $name { pub const fn empty() -> $name {
$name(0) $name(0)
} }
#[inline] #[inline]
pub fn all() -> $name { pub const fn all() -> $name {
$name($all) $name($all)
} }
#[inline] #[inline]
pub fn from_raw(x: $flag_type) -> Self { pub const fn from_raw(x: $flag_type) -> Self {
$name(x) $name(x)
} }
#[inline] #[inline]
pub fn as_raw(self) -> $flag_type { pub const fn as_raw(self) -> $flag_type {
self.0 self.0
} }
#[inline] #[inline]
@ -199,7 +199,7 @@ macro_rules! handle_nondispatchable {
} }
} }
impl $name { impl $name {
pub fn null() -> $name { pub const fn null() -> $name {
$name(0) $name(0)
} }
} }
@ -242,7 +242,7 @@ macro_rules! define_handle {
unsafe impl Send for $name {} unsafe impl Send for $name {}
unsafe impl Sync for $name {} unsafe impl Sync for $name {}
impl $name { impl $name {
pub fn null() -> Self { pub const fn null() -> Self {
$name(::std::ptr::null_mut()) $name(::std::ptr::null_mut())
} }
} }

View file

@ -122,7 +122,7 @@ pub fn define_handle_macro() -> Tokens {
unsafe impl Sync for $name {} unsafe impl Sync for $name {}
impl $name{ impl $name{
pub fn null() -> Self{ pub const fn null() -> Self{
$name(::std::ptr::null_mut()) $name(::std::ptr::null_mut())
} }
} }
@ -163,7 +163,7 @@ pub fn handle_nondispatchable_macro() -> Tokens {
} }
impl $name{ impl $name{
pub fn null() -> $name{ pub const fn null() -> $name{
$name(0) $name(0)
} }
} }
@ -232,20 +232,20 @@ pub fn vk_bitflags_wrapped_macro() -> Tokens {
impl $name { impl $name {
#[inline] #[inline]
pub fn empty() -> $name { pub const fn empty() -> $name {
$name(0) $name(0)
} }
#[inline] #[inline]
pub fn all() -> $name { pub const fn all() -> $name {
$name($all) $name($all)
} }
#[inline] #[inline]
pub fn from_raw(x: $flag_type) -> Self { $name(x) } pub const fn from_raw(x: $flag_type) -> Self { $name(x) }
#[inline] #[inline]
pub fn as_raw(self) -> $flag_type { self.0 } pub const fn as_raw(self) -> $flag_type { self.0 }
#[inline] #[inline]
pub fn is_empty(self) -> bool { pub fn is_empty(self) -> bool {