diff --git a/Changelog.md b/Changelog.md index 68c452f0..cd14be4d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `get_pipeline_executable_properties()`; - `get_pipeline_executable_statistics()`. The expected length of this array can be queried with the respective `*_len()` variant of these functions. +- `push_next()` has been marked as `unsafe` and users are encouraged to call `push_one()` instead. (#909) ## [0.38.0] - 2024-04-01 diff --git a/README.md b/README.md index 6b46827a..f3d13a31 100644 --- a/README.md +++ b/README.md @@ -91,19 +91,20 @@ let device: Device = instance ### Pointer chains -Use `base.push_next(ext)` to insert `ext` at the front of the pointer chain attached to `base`. +Use `base.push_one(ext)` to insert `ext` at the front of the pointer chain attached to `base`. If `ext` already contains a pointer chain of its own, +call `unsafe` `push_next()` instead. ```rust let mut variable_pointers = vk::PhysicalDeviceVariablePointerFeatures::default(); let mut corner = vk::PhysicalDeviceCornerSampledImageFeaturesNV::default(); let mut device_create_info = vk::DeviceCreateInfo::default() - .push_next(&mut corner) - .push_next(&mut variable_pointers); + .push_one(&mut corner) + .push_one(&mut variable_pointers); ``` -The generic argument of `.push_next()` only allows valid structs to extend a given struct (known as [`structextends` in the Vulkan registry](https://registry.khronos.org/vulkan/specs/1.3/styleguide.html#extensions-interactions), mapped to `Extends*` traits). -Only structs that are listed one or more times in any `structextends` will implement a `.push_next()`. +The generic argument of `.push_one()` only allows valid structs to extend a given struct (known as [`structextends` in the Vulkan registry](https://registry.khronos.org/vulkan/specs/1.3/styleguide.html#extensions-interactions), mapped to `Extends*` traits). +Only structs that are listed one or more times in any `structextends` will implement a `.push_one()`. ### Flags and constants as associated constants diff --git a/ash/src/lib.rs b/ash/src/lib.rs index 08b7fb96..91d44756 100644 --- a/ash/src/lib.rs +++ b/ash/src/lib.rs @@ -205,8 +205,8 @@ mod tests { <*mut _>::cast(&mut corner), ]; let mut device_create_info = vk::DeviceCreateInfo::default() - .push_next(&mut corner) - .push_next(&mut variable_pointers); + .push_one(&mut corner) + .push_one(&mut variable_pointers); let chain2: Vec<*mut vk::BaseOutStructure<'_>> = unsafe { vk::ptr_chain_iter(&mut device_create_info) .skip(1) diff --git a/ash/src/vk/definitions.rs b/ash/src/vk/definitions.rs index fd1631b3..298f8489 100644 --- a/ash/src/vk/definitions.rs +++ b/ash/src/vk/definitions.rs @@ -1283,15 +1283,40 @@ impl<'a> DeviceQueueCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -1377,15 +1402,40 @@ impl<'a> DeviceCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -1453,15 +1503,40 @@ impl<'a> InstanceCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -1599,15 +1674,40 @@ impl<'a> MemoryAllocateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -2003,15 +2103,40 @@ impl<'a> WriteDescriptorSet<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -2197,15 +2322,40 @@ impl<'a> BufferCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -2274,15 +2424,40 @@ impl<'a> BufferViewCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -2505,15 +2680,40 @@ impl<'a> BufferMemoryBarrier<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -2603,15 +2803,40 @@ impl<'a> ImageMemoryBarrier<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -2732,15 +2957,37 @@ impl<'a> ImageCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next(mut self, next: &'a mut T) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -2855,15 +3102,40 @@ impl<'a> ImageViewCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -3172,15 +3444,37 @@ impl<'a> BindSparseInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next(mut self, next: &'a mut T) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -3471,15 +3765,40 @@ impl<'a> ShaderModuleCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -3586,18 +3905,43 @@ impl<'a> DescriptorSetLayoutCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -3676,18 +4020,43 @@ impl<'a> DescriptorPoolCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -3738,18 +4107,43 @@ impl<'a> DescriptorSetAllocateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -3893,18 +4287,43 @@ impl<'a> PipelineShaderStageCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -3973,18 +4392,43 @@ impl<'a> ComputePipelineCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -4201,18 +4645,43 @@ impl<'a> PipelineVertexInputStateCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -4308,18 +4777,43 @@ impl<'a> PipelineTessellationStateCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -4390,18 +4884,43 @@ impl<'a> PipelineViewportStateCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -4512,18 +5031,43 @@ impl<'a> PipelineRasterizationStateCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -4615,18 +5159,43 @@ impl<'a> PipelineMultisampleStateCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -4755,18 +5324,43 @@ impl<'a> PipelineColorBlendStateCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -5131,18 +5725,43 @@ impl<'a> GraphicsPipelineCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -5811,15 +6430,40 @@ impl<'a> SamplerCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -5984,18 +6628,43 @@ impl<'a> CommandBufferInheritanceInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -6046,15 +6715,40 @@ impl<'a> CommandBufferBeginInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -6132,15 +6826,40 @@ impl<'a> RenderPassBeginInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -6512,15 +7231,40 @@ impl<'a> RenderPassCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -6561,15 +7305,37 @@ impl<'a> EventCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next(mut self, next: &'a mut T) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -6610,15 +7376,37 @@ impl<'a> FenceCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next(mut self, next: &'a mut T) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -7974,15 +8762,40 @@ impl<'a> SemaphoreCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -8044,15 +8857,40 @@ impl<'a> QueryPoolCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -8136,15 +8974,40 @@ impl<'a> FramebufferCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -8363,15 +9226,37 @@ impl<'a> SubmitInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next(mut self, next: &'a mut T) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -9434,15 +10319,40 @@ impl<'a> SwapchainCreateInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -9512,15 +10422,37 @@ impl<'a> PresentInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next(mut self, next: &'a mut T) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -11393,18 +12325,40 @@ impl<'a> PhysicalDeviceFeatures2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] - #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] + #[doc = r" chain will look like `A -> D -> B -> C`."] + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -11445,18 +12399,43 @@ impl<'a> PhysicalDeviceProperties2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -11497,15 +12476,40 @@ impl<'a> FormatProperties2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -11549,15 +12553,40 @@ impl<'a> ImageFormatProperties2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -11626,18 +12655,43 @@ impl<'a> PhysicalDeviceImageFormatInfo2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -11681,15 +12735,40 @@ impl<'a> QueueFamilyProperties2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -11730,18 +12809,43 @@ impl<'a> PhysicalDeviceMemoryProperties2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -12291,18 +13395,43 @@ impl<'a> PhysicalDeviceExternalBufferInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -13028,18 +14157,43 @@ impl<'a> PhysicalDeviceExternalSemaphoreInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -14451,15 +15605,40 @@ impl<'a> BindBufferMemoryInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -14552,15 +15731,40 @@ impl<'a> BindImageMemoryInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -16141,18 +17345,43 @@ impl<'a> PhysicalDeviceSurfaceInfo2KHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -16193,18 +17422,40 @@ impl<'a> SurfaceCapabilities2KHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] - #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] + #[doc = r" chain will look like `A -> D -> B -> C`."] + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -16245,15 +17496,40 @@ impl<'a> SurfaceFormat2KHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -16740,18 +18016,43 @@ impl<'a> ImageMemoryRequirementsInfo2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -16867,15 +18168,40 @@ impl<'a> MemoryRequirements2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -17276,18 +18602,43 @@ impl<'a> SamplerYcbcrConversionCreateInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -19378,18 +20729,43 @@ impl<'a> PhysicalDeviceLayeredApiPropertiesKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -19527,18 +20903,43 @@ impl<'a> DescriptorSetLayoutSupport<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -20575,18 +21976,43 @@ impl<'a> DebugUtilsMessengerCallbackDataEXT<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -21997,15 +23423,40 @@ impl<'a> AttachmentDescription2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -22060,15 +23511,40 @@ impl<'a> AttachmentReference2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -22174,15 +23650,40 @@ impl<'a> SubpassDescription2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -22272,15 +23773,40 @@ impl<'a> SubpassDependency2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -22361,15 +23887,40 @@ impl<'a> RenderPassCreateInfo2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -22437,15 +23988,37 @@ impl<'a> SubpassEndInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next(mut self, next: &'a mut T) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -23036,18 +24609,43 @@ impl<'a> AndroidHardwareBufferPropertiesANDROID<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -25893,18 +27491,43 @@ impl<'a> RayTracingPipelineCreateInfoNV<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -26020,18 +27643,43 @@ impl<'a> RayTracingPipelineCreateInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -26366,18 +28014,43 @@ impl<'a> AccelerationStructureCreateInfoNV<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -34408,18 +36081,43 @@ impl<'a> AccelerationStructureGeometryTrianglesDataKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -34825,18 +36523,43 @@ impl<'a> AccelerationStructureCreateInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -36633,18 +38356,43 @@ impl<'a> PhysicalDeviceClusterCullingShaderFeaturesHUAWEI<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -36855,15 +38603,37 @@ impl<'a> ImageBlit2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next(mut self, next: &'a mut T) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -36939,15 +38709,40 @@ impl<'a> BufferImageCopy2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -37204,15 +38999,37 @@ impl<'a> BlitImageInfo2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next(mut self, next: &'a mut T) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -38781,18 +40598,43 @@ impl<'a> GeneratedCommandsMemoryRequirementsInfoEXT<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -39110,18 +40952,43 @@ impl<'a> GeneratedCommandsInfoEXT<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -39275,18 +41142,43 @@ impl<'a> IndirectCommandsLayoutCreateInfoEXT<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -40097,15 +41989,40 @@ impl<'a> ImageMemoryBarrier2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -40202,15 +42119,40 @@ impl<'a> BufferMemoryBarrier2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -40383,18 +42325,40 @@ impl<'a> CommandBufferSubmitInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] - #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] + #[doc = r" chain will look like `A -> D -> B -> C`."] + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -40474,15 +42438,37 @@ impl<'a> SubmitInfo2<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next(mut self, next: &'a mut T) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -41586,18 +43572,43 @@ impl<'a> PhysicalDeviceVideoFormatInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -41735,15 +43746,40 @@ impl<'a> VideoProfileInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -41846,15 +43882,40 @@ impl<'a> VideoCapabilitiesKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -42056,18 +44117,43 @@ impl<'a> VideoReferenceSlotInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -42230,15 +44316,40 @@ impl<'a> VideoDecodeInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -43205,18 +45316,43 @@ impl<'a> VideoSessionCreateInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -43274,18 +45410,43 @@ impl<'a> VideoSessionParametersCreateInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -43326,18 +45487,43 @@ impl<'a> VideoSessionParametersUpdateInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -43382,18 +45568,43 @@ impl<'a> VideoEncodeSessionParametersGetInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -43435,18 +45646,43 @@ impl<'a> VideoEncodeSessionParametersFeedbackInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -43514,18 +45750,40 @@ impl<'a> VideoBeginCodingInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] - #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] + #[doc = r" chain will look like `A -> D -> B -> C`."] + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -43600,18 +45858,43 @@ impl<'a> VideoCodingControlInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -43763,15 +46046,40 @@ impl<'a> VideoEncodeInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -43942,18 +46250,43 @@ impl<'a> VideoEncodeQualityLevelPropertiesKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -44088,18 +46421,43 @@ impl<'a> VideoEncodeRateControlLayerInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -47068,18 +49426,43 @@ impl<'a> DescriptorBufferBindingInfoEXT<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -49502,15 +51885,37 @@ impl<'a> RenderingInfo<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next(mut self, next: &'a mut T) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -51026,15 +53431,40 @@ impl<'a> SubresourceLayout2KHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -52452,18 +54882,43 @@ impl<'a> ExportMetalObjectsInfoEXT<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -53894,18 +56349,43 @@ impl<'a> OpticalFlowSessionCreateInfoNV<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -54436,15 +56916,40 @@ impl<'a> DepthBiasInfoEXT<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -55873,15 +58378,40 @@ impl<'a> MemoryMapInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -56115,15 +58645,40 @@ impl<'a> ShaderCreateInfoEXT<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -56328,18 +58883,43 @@ impl<'a> ScreenBufferPropertiesQNX<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*mut T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*mut T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*mut _>::cast(next); self } } @@ -56882,18 +59462,43 @@ impl<'a> ExecutionGraphPipelineCreateInfoAMDX<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -57296,18 +59901,43 @@ impl<'a> BindDescriptorSetsInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -57372,15 +60002,40 @@ impl<'a> PushConstantsInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one(mut self, next: &'a mut T) -> Self { + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -57445,18 +60100,43 @@ impl<'a> PushDescriptorSetInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -57521,18 +60201,43 @@ impl<'a> PushDescriptorSetWithTemplateInfoKHR<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -57605,18 +60310,43 @@ impl<'a> SetDescriptorBufferOffsetsInfoEXT<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } @@ -57672,18 +60402,43 @@ impl<'a> BindDescriptorBufferEmbeddedSamplersInfoEXT<'a> { #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] #[doc = r" method only exists on structs that can be passed to a function directly. Only"] #[doc = r" valid extension structs can be pushed into the chain."] - #[doc = r" If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the"] + #[doc = r" If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut"] + #[doc = r" D)`, then the chain will look like `A -> D -> E -> B -> C`."] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring"] + #[doc = r" all non-`NULL` pointers to point to a valid Vulkan structure starting with the"] + #[doc = r" [`BaseOutStructure`] layout."] + pub unsafe fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + #[doc = r" Prepends the given extension struct between the root and the first pointer. This"] + #[doc = r" method only exists on structs that can be passed to a function directly. Only"] + #[doc = r" valid extension structs can be pushed into the chain."] + #[doc = r" If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the"] #[doc = r" chain will look like `A -> D -> B -> C`."] - pub fn push_next( + #[doc = r""] + #[doc = r" # Panics"] + #[doc = r" If `next` contains a pointer chain of its own, this function will panic. Call"] + #[doc = r" `unsafe` [`Self::push_next()`] to insert this chain instead."] + pub fn push_one( mut self, next: &'a mut T, ) -> Self { - unsafe { - let next_ptr = <*const T>::cast(next); - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + assert!( + base.p_next.is_null(), + "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)" + ); + base.p_next = self.p_next as _; + self.p_next = <*const _>::cast(next); self } } diff --git a/generator/src/lib.rs b/generator/src/lib.rs index 73da54a3..04666517 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -2329,24 +2329,47 @@ fn derive_getters_and_setters( /// Prepends the given extension struct between the root and the first pointer. This /// method only exists on structs that can be passed to a function directly. Only /// valid extension structs can be pushed into the chain. - /// If the chain looks like `A -> B -> C`, and you call `x.push_next(&mut D)`, then the + /// If the chain looks like `A -> B -> C` and `D -> E`, and you call `A.push_next(&mut + /// D)`, then the chain will look like `A -> D -> E -> B -> C`. + /// + /// # Safety + /// This function will walk the [`BaseOutStructure::p_next`] chain of `next`, requiring + /// all non-`NULL` pointers to point to a valid Vulkan structure starting with the + /// [`BaseOutStructure`] layout. + pub unsafe fn push_next(mut self, next: &'a mut T) -> Self { + let next_ptr = <*#mutability T>::cast(next); + // `next` here can contain a pointer chain. This means that we must correctly + // attach he head to the root and the tail to the rest of the chain + // For example: + // + // next = A -> B + // Before: `Root -> C -> D -> E` + // After: `Root -> A -> B -> C -> D -> E` + // ^^^^^^ + // next chain + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.p_next as _; + self.p_next = next_ptr; + self + } + + /// Prepends the given extension struct between the root and the first pointer. This + /// method only exists on structs that can be passed to a function directly. Only + /// valid extension structs can be pushed into the chain. + /// If the chain looks like `A -> B -> C`, and you call `A.push_one(&mut D)`, then the /// chain will look like `A -> D -> B -> C`. - pub fn push_next(mut self, next: &'a mut T) -> Self { - unsafe { - let next_ptr = <*#mutability T>::cast(next); - // `next` here can contain a pointer chain. This means that we must correctly - // attach he head to the root and the tail to the rest of the chain - // For example: - // - // next = A -> B - // Before: `Root -> C -> D -> E` - // After: `Root -> A -> B -> C -> D -> E` - // ^^^^^^ - // next chain - let last_next = ptr_chain_iter(next).last().unwrap(); - (*last_next).p_next = self.p_next as _; - self.p_next = next_ptr; - } + /// + /// # Panics + /// If `next` contains a pointer chain of its own, this function will panic. Call + /// `unsafe` [`Self::push_next()`] to insert this chain instead. + pub fn push_one(mut self, next: &'a mut T) -> Self { + // SAFETY: All implementors of T are required to have the `BaseOutStructure` layout + let base = unsafe { &mut *<*mut T>::cast::>(next) }; + // `next` here can contain a pointer chain. This function refuses to insert the struct, + // in favour of calling unsafe push_next(). + assert!(base.p_next.is_null(), "push_one() expects a struct without an existing p_next pointer chain (equal to NULL)"); + base.p_next = self.p_next as _; + self.p_next = <*#mutability _>::cast(next); self } }