Skip to content
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

Port Duration::from_secs_f32|64 from std #576

Merged
merged 1 commit into from
May 10, 2023

Conversation

CryZe
Copy link
Contributor

@CryZe CryZe commented May 9, 2023

This ports the algorithm for constructing Duration from floating point seconds from std. The new algorithm in std uses bit manipulation to construct the Duration with the most precision possible. Additionally this adds saturating and checked variants of those functions.

Original std PR: rust-lang/rust#90247

@CryZe CryZe force-pushed the duration-parse-float-std branch from bde3232 to 97ac8d9 Compare May 9, 2023 18:57
@codecov
Copy link

codecov bot commented May 9, 2023

Codecov Report

Merging #576 (d6cdb26) into main (22ae579) will increase coverage by 0.0%.
The diff coverage is 100.0%.

@@          Coverage Diff          @@
##            main    #576   +/-   ##
=====================================
  Coverage   95.7%   95.7%           
=====================================
  Files         79      79           
  Lines       8779    8795   +16     
=====================================
+ Hits        8405    8421   +16     
  Misses       374     374           
Impacted Files Coverage Δ
time/src/duration.rs 100.0% <100.0%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@CryZe CryZe force-pushed the duration-parse-float-std branch from 97ac8d9 to 744a99f Compare May 9, 2023 19:16
This ports the algorithm for constructing `Duration` from floating point
seconds from `std`. The new algorithm in `std` uses bit manipulation to
construct the `Duration` with the most precision possible. Additionally
this adds `saturating` and `checked` variants of those functions.

Original `std` PR: rust-lang/rust#90247

Co-authored-by: Ted Wollman <25165500+TheTedder@users.noreply.github.com>
@CryZe CryZe force-pushed the duration-parse-float-std branch from 744a99f to d6cdb26 Compare May 9, 2023 19:29
@jhpratt jhpratt added A-core Area: anything not otherwise covered C-enhancement Category: an enhancement with existing code labels May 10, 2023
@jhpratt jhpratt self-requested a review May 10, 2023 07:33
@jhpratt
Copy link
Member

jhpratt commented May 10, 2023

Having this code and the code from std side-by-side, I've (unsurprisingly) confirmed that it is the same for everything except where noted. I initially questioned the use of break 'value ..., but then realized the context in quick the macro was being used meant that a simple return would not suffice.

I have no changes to request, so I'm merging it as-is. Thank you for the PR!

@jhpratt jhpratt merged commit e83d01f into time-rs:main May 10, 2023
@jhpratt jhpratt removed their request for review May 10, 2023 09:17
@CryZe CryZe deleted the duration-parse-float-std branch May 10, 2023 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: anything not otherwise covered C-enhancement Category: an enhancement with existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants