Add a Safety section to the documentation of create_instance and create_device (#272)

* Add a Safety section to the documentation of `create_instance` and `create_device`

* Change doc links back to original format
This commit is contained in:
Joshua Suskalo 2020-02-29 14:24:39 -06:00 committed by GitHub
parent 98def0a4e3
commit 39a6a8552a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -77,6 +77,10 @@ pub trait EntryV1_0 {
type Instance; type Instance;
fn fp_v1_0(&self) -> &vk::EntryFnV1_0; fn fp_v1_0(&self) -> &vk::EntryFnV1_0;
fn static_fn(&self) -> &vk::StaticFn; fn static_fn(&self) -> &vk::StaticFn;
/// # Safety
/// In order for the created `Instance` to be valid for the duration of its
/// usage, the `Entry` this was called on must be dropped later than the
/// resulting `Instance`.
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateInstance.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateInstance.html>"]
unsafe fn create_instance( unsafe fn create_instance(
&self, &self,
@ -138,6 +142,10 @@ pub trait EntryV1_0 {
impl<L> EntryV1_0 for EntryCustom<L> { impl<L> EntryV1_0 for EntryCustom<L> {
type Instance = Instance; type Instance = Instance;
/// # Safety
/// In order for the created `Instance` to be valid for the duration of its
/// usage, the `Entry` this was called on must be dropped later than the
/// resulting `Instance`.
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateInstance.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateInstance.html>"]
unsafe fn create_instance( unsafe fn create_instance(
&self, &self,

View file

@ -38,6 +38,10 @@ impl Instance {
impl InstanceV1_0 for Instance { impl InstanceV1_0 for Instance {
type Device = Device; type Device = Device;
/// # Safety
/// In order for the created `Device` to be valid for the duration of its
/// usage, the `Instance` this was called on must be dropped later than the
/// resulting `Device`.
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDevice.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDevice.html>"]
unsafe fn create_device( unsafe fn create_device(
&self, &self,
@ -288,6 +292,10 @@ pub trait InstanceV1_0 {
type Device; type Device;
fn handle(&self) -> vk::Instance; fn handle(&self) -> vk::Instance;
fn fp_v1_0(&self) -> &vk::InstanceFnV1_0; fn fp_v1_0(&self) -> &vk::InstanceFnV1_0;
/// # Safety
/// In order for the created `Device` to be valid for the duration of its
/// usage, the `Instance` this was called on must be dropped later than the
/// resulting `Device`.
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDevice.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDevice.html>"]
unsafe fn create_device( unsafe fn create_device(
&self, &self,