-
Notifications
You must be signed in to change notification settings - Fork 192
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
Permit builders to be passed in slices #223
Comments
Quick (possibly dumb) idea: can we make all the Builder functions accept only other builders or slices of them? This would be a breaking change, but with positive safety implications and it's not unprecedented. |
Yes this is something that is a bit annoying. I think what we can do is this
where Just a few quick thoughts, I'll have a look at how we can improve the API. Thanks for opening the issue :). |
It can be done the other way around - add lifetime parameter and return built struct with same lifetime from It would be impossible to accidentally use reference to too short-lived temporary value in builder and then use built structure in API calls when value is already dropped. |
I don't actually get a compiler error here - although weirdly, it only manifests as an issue with Edit: Ah, I now understand that the |
@MaikKlein Is the whole idea undesirable, or just the implementation with |
I am actually thinking of bringing this PR back. I just didn't like the additional complexity and it is hard to get feedback. But I think in this case it might be worth it. |
This will now be possible thanks to #602: the builder structs are gone and their functions have been implemented directly on the Vulkan struct, which now carries a |
@MaikKlein @Ralith First of all thanks for your work on builders, they make it so much easier to define only what is required.
Since the Builder objects are transparent, I tried this code, which I think is safe to do:
And it seems to be working just fine. It has the obvious benefit for tracking lifetimes, so the compiler will error out if I try this:
And this is something I run into periodically when I need to call
build()
.Could ash somehow generate functions&structs that are compatible with, in the case of
RenderPassCreateInfo
,&[vk::SubpassDescription]
and&[vk::SubpassDescriptionBuilder]
at the same time?The text was updated successfully, but these errors were encountered: