Skip to content

Commit b33a833

Browse files
committed
Clean the codes a bit
1 parent 26512c1 commit b33a833

File tree

1 file changed

+5
-5
lines changed
  • library/core/src/convert

1 file changed

+5
-5
lines changed

library/core/src/convert/num.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use safety::{ensures, requires};
44
#[cfg(kani)]
55
use crate::kani;
66

7+
#[allow(unused_imports)]
8+
use crate::ub_checks::float_to_int_in_range;
9+
710
mod private {
811
/// This trait being unreachable from outside the crate
912
/// prevents other implementations of the `FloatToInt` trait,
@@ -31,11 +34,8 @@ macro_rules! impl_float_to_int {
3134
#[inline]
3235
#[requires(
3336
!self.is_nan() &&
34-
!self.is_infinite() &&
35-
// Even if <$Int>::MIN < <$Float>::MIN or <$Int>::MAX > <$Float>::MAX,
36-
// the bounds would be -Inf or Inf, so they'll work anyways
37-
self > <$Int>::MIN as $Float - 1.0 &&
38-
self < <$Int>::MAX as $Float + 1.0
37+
self.is_finite() &&
38+
float_to_int_in_range::<$Float, $Int>(self)
3939
)]
4040
#[ensures(|&result|{
4141
let fract = self - result as $Float;

0 commit comments

Comments
 (0)