We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d630718 commit 65b0fc4Copy full SHA for 65b0fc4
src/sys/time.rs
@@ -391,6 +391,7 @@ impl TimeSpec {
391
self.0.tv_nsec
392
}
393
394
+ #[allow(clippy::unnecessary_fallible_conversions)]
395
pub fn try_from_duration(
396
duration: Duration,
397
) -> Result<Self, TryFromDurationError> {
@@ -399,7 +400,12 @@ impl TimeSpec {
399
400
.as_secs()
401
.try_into()
402
.map_err(|_| TryFromDurationError)?;
- ts.tv_nsec = duration.subsec_nanos().into();
403
+ // There are targets with tv_nsec being i32. Use the fallible conversion for all targets as
404
+ // we are returning a Result due to the previous conversion anyway.
405
+ ts.tv_nsec = duration
406
+ .subsec_nanos()
407
+ .try_into()
408
+ .map_err(|_| TryFromDurationError)?;
409
Ok(TimeSpec(ts))
410
411
0 commit comments