Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Handle::is_null() #694

Merged
merged 1 commit into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Added `VK_EXT_pipeline_properties` device extension (#622)
- Added `Handle::is_null()` to allow checking if a handle is a `NULL` value (#694)
- Update Vulkan-Headers to 1.3.246 (#697, #723)
- Added `VK_KHR_performance_query` device extension (#726)
- Added `VK_EXT_shader_object` device extension (#732)
Expand Down
15 changes: 14 additions & 1 deletion ash/src/vk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,21 @@ pub(crate) unsafe fn ptr_chain_iter<T>(ptr: &mut T) -> impl Iterator<Item = *mut
Some(old)
})
}
pub trait Handle {
pub trait Handle: Sized {
const TYPE: ObjectType;
fn as_raw(self) -> u64;
fn from_raw(_: u64) -> Self;

/// Returns whether the handle is a `NULL` value.
///
/// # Example
///
/// ```
/// # use ash::vk::{Handle, Instance};
/// let instance = Instance::null();
/// assert!(instance.is_null());
/// ```
fn is_null(self) -> bool {
self.as_raw() == 0
}
}