[wgpu-hal] Change the DropCallback
API to use FnOnce
instead of FnMut
#6482
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Connections
This refines the change I made in #6164
Description
I initially made the
DropCallback
API useFnMut
. This seemed like a good choice at the time, since we only get&mut self
access to theDropGuard
in itsDrop
implementation. After some time it became apparent to me that at least a part of the users of this API will want to supply a closure which just holds some kind of a reference-counted wrapper around the corresponding resource that would drop it when called, thus freeing the resource. With the current API they have to do weird stuff to achieve this behavior, becauseFnMut
cannot consume its captures:With this change they could consume the capture:
This seems a lot more intuitive.
Testing
Things still compile and there is no difference in test passes.
Checklist
cargo fmt
.taplo format
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
This just fails
cargo xtask test
to run tests.129 tests fail on my machine, with or without the changes
CHANGELOG.md
. See simple instructions inside file.