Skip to content

Instantly share code, notes, and snippets.

View kiljacken's full-sized avatar
🦀

Emil Lauridsen kiljacken

🦀
  • Danske Bank
  • Copenagen, Denmark
View GitHub Profile
macro_rules! inner_ptr {
($gpuva:expr, $($f:tt)*) 0> ({
fn uninit_from<T: GPUStruct>(_: &GPUWeakPointer<T>) -> MaybeUninit<T::Raw<'static>> {
core::mem::MaybeUninit::uninit()
}
let tmp = uninit_from($gpuva);
// ... All the stuff up to and including `inner.offset_from(...)`
let off = inner.offset_from(...);
let outer = tmp.as_ptr();
fn out_from<T: GPUStruct, U>(gpuva: &GPUWeakPointer<T>) -> GPUWeakPointer<U> {
// 1: Only my crate can implement *and* use it (plain visibilty)
pub(crate) trait AllocImpl {}
// 2: Only my module can implement the trait, others can use it
mod private {
pub trait Sealed {}
}
pub trait AllocImpl: private::Sealed {}