Closed
Description
Feature gate: #![feature(duration_checked_float)]
This is a tracking issue for checked methods to construct a duration from a floating-point value of seconds without panicking.
Public API
// core::time
impl Duration {
pub const fn try_from_secs_f32(secs: f32) -> Result<Duration, FromFloatSecsError>;
pub const fn try_from_secs_f64(secs: f64) -> Result<Duration, FromFloatSecsError>;
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct FromFloatSecsError { ... }
impl core::fmt::Display for FromFloatSecsError { ... }
// std::error
impl std::error::Error for FromFloatSecsError { ... }
Steps / History
- Implementation
- Final commenting period (FCP)
- Stabilization PR
Unresolved Questions
- What should the error type be called?
- Originally
FromSecsError
. - Changed to
FromFloatSecsError
in Improve Duration::try_from_secs_f32/64 accuracy by directly processing exponent and mantissa #90247 - Changed and finalised as
TryFromFloatSecsError
in Stabilizeduration_checked_float
#102271
- Originally