[−][src]Macro vulkayes_core::vk_builder_wrap
Wraps an ash builder in a #[repr(transparent)]
struct.
Usage:
vk_builder_wrap! { /// Doc comment pub struct Foo ['a] { // the `=> BuilderTargetType` part is optional and generates an additional Transparent unsafe impl builder: BuilderType<'a> => BuilderTargetType } impl ['a] { pub fn new(param: &'a u32) -> Self { todo!() } } }
expands to:
#[doc = r###"Doc comment"###] #[repr(transparent)] pub struct Foo<'a> { builder: BuilderType<'a> } impl<'a> Foo<'a> { pub const unsafe fn from_raw( builder: BuilderType<'a> ) -> Self { Foo { builder } } pub fn new(param: &'a u32) -> Self { todo!() } } impl<'a> std::ops::Deref for Foo<'a> { type Target = BuilderType<'a>; fn deref(&self) -> &Self::Target { &self.builder } } impl<'a> std::ops::DerefMut for Foo<'a> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.builder } } unsafe impl<'a> vulkayes_core::util::transparent::Transparent for Foo<'a> { type Target = BuilderType<'a>; } // This is optional unsafe impl<'a> vulkayes_core::util::transparent::Transparent for BuilderType<'a> { type Target = BuilderTargetType ; } impl<'a> std::fmt::Debug for Foo<'a> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.debug_struct(stringify!( Foo )) .field("self.builder.deref()", std::ops::Deref::deref(&self.builder)) .finish() } }