Improve ergonomics of platform_support
's Instant
#17577
Merged
+4
−4
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.
Objective
bevy_time
more ergonomic inno_std
environments.Currently
bevy_time
expects the getter in environments where time can't be obtained automatically via the instruction set or the standard library to be of type*mut fn() -> Duration
.fn()
is already a function pointer, so*mut fn()
is a pointer to a function pointer. This is harder to use and error prone since creating a pointer out of something like&mut fn() -> Duration
when the lifetime of the reference isn't static will lead to an undefined behavior once the reference is freedSolution
fn() -> Duration
insteadTesting
bevy_time
heavily, see: bevydate_time for usage of the Instant's getter.Showcase
Click to view showcase
test2.mp4
Migration Guide
This is a breaking change but it's not for people coming from Bevy v0.15
Small thank you note
Thanks to my friend https://github.com/repnop for helping me understand how to deal with function pointers in
unsafe
environments