-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Merged by Bors] - Remaining fn in Timer #5971
Conversation
For symmetry with |
crates/bevy_time/src/timer.rs
Outdated
/// use std::time::Duration; | ||
/// let mut timer = Timer::from_seconds(2.0, false); | ||
/// timer.tick(Duration::from_secs_f32(0.5)); | ||
/// assert_eq!(timer.remaining(), 1.5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Float equality checking is a bad habit; we should have some error bars here.
I purpose using float-cmp to properly compare floats in an error range. |
We don't have to pull in another crate. I think Another alternative is following the suggestion of this clippy lint: |
LGTM once the float equality check is addressed :) |
Other parts of timer implementation also use implicit float comparison. Maybe create another issue for fixing that? |
|
(Oops, approved by accident; don't count it) |
In my opinion, the doc tests you added are not really needed and should be removed. But it's the current documentation style of For me, having that many code examples that show "obvious" behaviours make docs less readable: https://docs.rs/bevy/latest/bevy/prelude/struct.Timer.html Approving this PR as is, but I think an issue or a followup PR should be opened to remove most of the doc examples. |
bors r+ |
# Objective Fixes #5963 ## Solution Add remaining fn in Timer class, this function only minus total duration with elapsed time. Co-authored-by: Sergi-Ferrez <61662926+Sergi-Ferrez@users.noreply.github.com>
Pull request successfully merged into main. Build succeeded: |
# Objective Fixes bevyengine#5963 ## Solution Add remaining fn in Timer class, this function only minus total duration with elapsed time. Co-authored-by: Sergi-Ferrez <61662926+Sergi-Ferrez@users.noreply.github.com>
# Objective Fixes bevyengine#5963 ## Solution Add remaining fn in Timer class, this function only minus total duration with elapsed time. Co-authored-by: Sergi-Ferrez <61662926+Sergi-Ferrez@users.noreply.github.com>
# Objective Fixes bevyengine#5963 ## Solution Add remaining fn in Timer class, this function only minus total duration with elapsed time. Co-authored-by: Sergi-Ferrez <61662926+Sergi-Ferrez@users.noreply.github.com>
Objective
Fixes #5963
Solution
Add remaining fn in Timer class, this function only minus total duration with elapsed time.