Describe the bug
The Rust Pattern of wrapping one type in another was suggested to me as a solution of working with reference counting.
struct RcA(a-sys::A);
pub struct A(Rc<RcA>);
The Deref trait would remove .0 from all over the place. The point is to implement Drop for RcA such that the destructor for a-sys::A would be called. My target is ash/Vulkan.
A real world example: Much of the boilerplate is hidden inside macros, so only the unique parts are shown.
A keen eye would have noticed that Device has a one-of Deref, actually two types like that. It's because "use ash::Device as VkDevice" != "use ash::vk; vk::Device"
Version (please complete the following information):
rustup --version
cargo --version
rustc --version
$ exit
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.56.0-nightly (ad02dc46b 2021-08-26)`
cargo 1.56.0-nightly (e96bdb0c3 2021-08-17)
rustc 1.56.0-nightly (ad02dc46b 2021-08-26)
Version of derivative: 2.2.0
Additional context
I also do a lot of testing with CI and it's obviously not easy to run the above --version script. Though I need that information as well, so if you look at https://gitlab.com/cheako/ash-tray-rs/-/pipelines and https://gitlab.com/cheako/hazel-rs/-/pipelines you'll get more examples of version info and resulting errors. Thought I don't believe you'll find errors there, even for the fixed errors because generic is not Clone where I don't think I pushed any.
Also note that I'd love any criticism of this code, it often keeps me up at night wondering if this code is any good... And now I can add wondering if it's too much Golf.
Describe the bug The Rust Pattern of wrapping one type in another was suggested to me as a solution of working with reference counting.
The
Deref
trait would remove.0
from all over the place. The point is to implementDrop
forRcA
such that the destructor fora-sys::A
would be called. My target is ash/Vulkan.A real world example: Much of the boilerplate is hidden inside macros, so only the unique parts are shown.
Fence
andCommandBuffer
https://gitlab.com/cheako/ash-tray-rs/-/blob/c9a1ea4db239fca214f0cea09030096fc0390c3b/src/vk_helper.rs#L598-925 are two extremes andDescriptoSet
is a complex example as well.Expected behavior
Most of the types(notably
Device
andFence
from above) are defined with this macro:A keen eye would have noticed that
Device
has a one-ofDeref
, actually two types like that. It's because"use ash::Device as VkDevice" != "use ash::vk; vk::Device"
Version (please complete the following information):
derivative
:2.2.0
Additional context I also do a lot of testing with CI and it's obviously not easy to run the above
--version
script. Though I need that information as well, so if you look at https://gitlab.com/cheako/ash-tray-rs/-/pipelines and https://gitlab.com/cheako/hazel-rs/-/pipelines you'll get more examples of version info and resulting errors. Thought I don't believe you'll find errors there, even for the fixed errors because generic is notClone
where I don't think I pushed any.Also note that I'd love any criticism of this code, it often keeps me up at night wondering if this code is any good... And now I can add wondering if it's too much Golf.