Skip to content

Commit

Permalink
Clean the codes a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
ShoyuVanilla committed Dec 28, 2024
1 parent 26512c1 commit b33a833
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions library/core/src/convert/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use safety::{ensures, requires};
#[cfg(kani)]
use crate::kani;

#[allow(unused_imports)]
use crate::ub_checks::float_to_int_in_range;

mod private {
/// This trait being unreachable from outside the crate
/// prevents other implementations of the `FloatToInt` trait,
Expand Down Expand Up @@ -31,11 +34,8 @@ macro_rules! impl_float_to_int {
#[inline]
#[requires(
!self.is_nan() &&
!self.is_infinite() &&
// Even if <$Int>::MIN < <$Float>::MIN or <$Int>::MAX > <$Float>::MAX,
// the bounds would be -Inf or Inf, so they'll work anyways
self > <$Int>::MIN as $Float - 1.0 &&
self < <$Int>::MAX as $Float + 1.0
self.is_finite() &&
float_to_int_in_range::<$Float, $Int>(self)
)]
#[ensures(|&result|{
let fract = self - result as $Float;
Expand Down

0 comments on commit b33a833

Please sign in to comment.