-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Stabilize duration_checked_float
#102271
Stabilize duration_checked_float
#102271
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
r? @scottmcm (rust-highfive has picked a reviewer for you, use r? to override) |
Thanks for continuing along with this. The error changes lgtm. |
Since it looks like this hasn't had an FCP, |
☔ The latest upstream changes (presumably #102051) made this pull request unmergeable. Please resolve the merge conflicts. |
Pushed a rebase due to the |
@rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
…ro, r=thomcc Fix `Duration::{try_,}from_secs_f{32,64}(-0.0)` Make `Duration::{try_,}from_secs_f{32,64}(-0.0)` return `Duration::ZERO` (as they did before rust-lang#90247) instead of erroring/panicking. I'll update this PR to remove the `#![feature(duration_checked_float)]` if rust-lang#102271 is merged before this PR. Tracking issue for `try_from_secs_f{32,64}`: rust-lang#83400
☔ The latest upstream changes (presumably #103069) made this pull request unmergeable. Please resolve the merge conflicts. |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
Tracking issue: - #83400
Pushed a rebase to address the merge conflict from #103059. It looks like the FCP is complete, so once CI passes I think this is ready for a stamp and merge. |
@joshtriplett I believe this is ready to be merged since the FCP has concluded. |
Did this miss the beta cutoff? 😢 |
@Amanieu @BurntSushi @dtolnay @joshtriplett @m-ou-se @yaahc can one of you r+ this PR to merge it? This FCP successfully completed 8 days ago. |
@bors r+ |
…on-try-from-secs-float, r=dtolnay Stabilize `duration_checked_float` ## Stabilization Report This stabilization report is for a stabilization of `duration_checked_float`, tracking issue: rust-lang#83400. ### Implementation History - rust-lang#82179 - rust-lang#90247 - rust-lang#96051 - Changed error type to `FromFloatSecsError` in rust-lang#90247 - rust-lang#96051 changes the rounding mode to round-to-nearest instead of truncate. ## API Summary This stabilization report proposes the following API to be stabilized in `core`, along with their re-exports in `std`: ```rust // core::time impl Duration { pub const fn try_from_secs_f32(secs: f32) -> Result<Duration, TryFromFloatSecsError>; pub const fn try_from_secs_f64(secs: f64) -> Result<Duration, TryFromFloatSecsError>; } #[derive(Debug, Clone, PartialEq, Eq)] pub struct TryFromFloatSecsError { ... } impl core::fmt::Display for TryFromFloatSecsError { ... } impl core::error::Error for TryFromFloatSecsError { ... } ``` These functions are made const unstable under `duration_consts_float`, tracking issue rust-lang#72440. There is an open question in the tracking issue around what the error type should be called which I was hoping to resolve in the context of an FCP. In this stabilization PR, I have altered the name of the error type to `TryFromFloatSecsError`. In my opinion, the error type shares the name of the method (adjusted to accommodate both types of floats), which is consistent with other error types in `core`, `alloc` and `std` like `TryReserveError` and `TryFromIntError`. ## Experience Report Code such as this is ready to be converted to a checked API to ensure it is panic free: ```rust impl Time { pub fn checked_add_f64(&self, seconds: f64) -> Result<Self, TimeError> { // Fail safely during `f64` conversion to duration if seconds.is_nan() || seconds.is_infinite() { return Err(TzOutOfRangeError::new().into()); } if seconds.is_sign_positive() { self.checked_add(Duration::from_secs_f64(seconds)) } else { self.checked_sub(Duration::from_secs_f64(-seconds)) } } } ``` See: artichoke/artichoke#2194. ``@rustbot`` label +T-libs-api -T-libs cc ``@mbartlett21``
Rollup of 7 pull requests Successful merges: - rust-lang#99578 (Remove redundant lifetime bound from `impl Borrow for Cow`) - rust-lang#99939 (Sort tests at compile time, not at startup) - rust-lang#102271 (Stabilize `duration_checked_float`) - rust-lang#102766 (Don't link to `libresolv` in libstd on Darwin) - rust-lang#103277 (Update libstd's libc to 0.2.135 (to make `libstd` no longer pull in `libiconv.dylib` on Darwin)) - rust-lang#103437 (Sync rustc_codegen_cranelift) - rust-lang#103466 (Fix grammar in docs for std::io::Read) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Stabilization Report
This stabilization report is for a stabilization of
duration_checked_float
, tracking issue: #83400.Implementation History
Duration::try_from_secs_{f32, f64}
#82179FromFloatSecsError
in Improve Duration::try_from_secs_f32/64 accuracy by directly processing exponent and mantissa #90247API Summary
This stabilization report proposes the following API to be stabilized in
core
, along with their re-exports instd
:These functions are made const unstable under
duration_consts_float
, tracking issue #72440.There is an open question in the tracking issue around what the error type should be called which I was hoping to resolve in the context of an FCP.
In this stabilization PR, I have altered the name of the error type to
TryFromFloatSecsError
. In my opinion, the error type shares the name of the method (adjusted to accommodate both types of floats), which is consistent with other error types incore
,alloc
andstd
likeTryReserveError
andTryFromIntError
.Experience Report
Code such as this is ready to be converted to a checked API to ensure it is panic free:
See: artichoke/artichoke#2194.
@rustbot label +T-libs-api -T-libs
cc @mbartlett21