diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b8cd2937..420a3f8f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@1.69.0 + - uses: dtolnay/rust-toolchain@1.75.0 - name: Check ash, ash-window and ash-rewrite run: cargo check -p ash -p ash-rewrite -p ash-window --all-features - name: Check ash with no_std diff --git a/ash-rewrite/Cargo.toml b/ash-rewrite/Cargo.toml index 77cdc05e4..852659e7a 100644 --- a/ash-rewrite/Cargo.toml +++ b/ash-rewrite/Cargo.toml @@ -18,7 +18,7 @@ categories = [ documentation = "https://docs.rs/ash" edition = "2021" # TODO: reevaluate, then update in ci.yml -rust-version = "1.69.0" +rust-version = "1.75.0" [dependencies] libloading = { version = "0.8", optional = true } diff --git a/ash-window/Cargo.toml b/ash-window/Cargo.toml index fc04e14a1..d57733d67 100644 --- a/ash-window/Cargo.toml +++ b/ash-window/Cargo.toml @@ -16,7 +16,7 @@ categories = [ "rendering::graphics-api" ] edition = "2021" -rust-version = "1.69.0" +rust-version = "1.75.0" [dependencies] ash = { path = "../ash", version = "0.38", default-features = false, features = ["std"] } diff --git a/ash/Cargo.toml b/ash/Cargo.toml index f0400b0a7..73e018662 100644 --- a/ash/Cargo.toml +++ b/ash/Cargo.toml @@ -19,7 +19,7 @@ categories = [ "rendering::graphics-api" ] edition = "2021" -rust-version = "1.69.0" +rust-version = "1.75.0" [dependencies] libloading = { version = "0.8", optional = true } diff --git a/ash/src/util.rs b/ash/src/util.rs index 30f8b7ffc..b84f40674 100644 --- a/ash/src/util.rs +++ b/ash/src/util.rs @@ -185,8 +185,8 @@ pub trait NextChainExt<'a>: TaggedStructure<'a> { self } /// Returns a mutable iterator over the entire extension chain attached to `Self` - fn iter_next_chain_mut(&'a mut self) -> impl Iterator> + 'a { - (0..).scan(self.as_base_mut().p_next, |p_ptr, _| unsafe { + fn iter_next_chain_mut(&mut self) -> impl Iterator> { + (0..).scan(self.as_base_mut().p_next, move |p_ptr, _| unsafe { if p_ptr.is_null() { return None; } @@ -197,7 +197,7 @@ pub trait NextChainExt<'a>: TaggedStructure<'a> { }) } /// Returns an iterator over the entire extension chain attached to `Self` - fn iter_next_chain(&'a self) -> impl Iterator> + 'a { + fn iter_next_chain(&self) -> impl Iterator> { (0..).scan(self.as_base().p_next, |p_ptr, _| unsafe { if p_ptr.is_null() { return None; @@ -319,6 +319,22 @@ impl<'a> TaggedObject<'a> { pub fn from_mut + ?Sized>(obj: &mut T) -> &mut Self { unsafe { &mut *(<*mut T>::cast(obj)) } } + pub fn next(&self) -> Option<&Self> { + unsafe { + if self.as_base().p_next.is_null() { + return None; + } + Some(TaggedObject::from_raw(self.as_base().p_next)) + } + } + pub fn next_mut(&mut self) -> Option<&mut Self> { + unsafe { + if self.as_base().p_next.is_null() { + return None; + } + Some(TaggedObject::from_raw_mut(self.as_base_mut().p_next)) + } + } pub fn tag(&self) -> vk::StructureType { self.as_base().s_type } diff --git a/ash/src/vk/prelude.rs b/ash/src/vk/prelude.rs index a3739ba15..e60f02495 100644 --- a/ash/src/vk/prelude.rs +++ b/ash/src/vk/prelude.rs @@ -57,16 +57,19 @@ impl From for vk::Rect2D { } } +/// Marker trait for tagged vulkan structures. +/// /// Structures implementing this trait are layout-compatible with [`vk::BaseInStructure`] and -/// [`vk::BaseOutStructure`]. Such structures have an `s_type` field indicating its type, which -/// must always match the value of [`TaggedStructure::STRUCTURE_TYPE`]. +/// [`vk::BaseOutStructure`]. Types implementing this trait have an `s_type` field indicating +/// its type, which must always match the value of [`TaggedStructure::STRUCTURE_TYPE`], unless +/// it is a [`crate::util::TaggedObject`]. pub unsafe trait TaggedStructure<'a> { const STRUCTURE_TYPE: vk::StructureType; fn as_base_mut(&mut self) -> &mut vk::BaseOutStructure<'a> { - unsafe { &mut *(<*mut Self>::cast(self) as *mut vk::BaseOutStructure<'a>) } + unsafe { &mut *(<*mut Self>::cast(self)) } } fn as_base(&self) -> &vk::BaseInStructure<'a> { - unsafe { &*(<*const Self>::cast(self) as *const vk::BaseInStructure<'a>) } + unsafe { &*(<*const Self>::cast(self)) } } }