@@ -594,8 +594,22 @@ impl<T> NotNan<T> {
594594 /// # Safety
595595 ///
596596 /// Behaviour is undefined if `val` is NaN
597+ #[ deprecated(
598+ since = "2.5.0" ,
599+ note = "Please use the new_unchecked function instead."
600+ ) ]
597601 #[ inline]
598602 pub const unsafe fn unchecked_new ( val : T ) -> Self {
603+ Self :: new_unchecked ( val)
604+ }
605+
606+ /// Create a `NotNan` value from a value that is guaranteed to not be NaN
607+ ///
608+ /// # Safety
609+ ///
610+ /// Behaviour is undefined if `val` is NaN
611+ #[ inline]
612+ pub const unsafe fn new_unchecked ( val : T ) -> Self {
599613 NotNan ( val)
600614 }
601615}
@@ -666,7 +680,7 @@ impl From<NotNan<f32>> for NotNan<f64> {
666680 #[ inline]
667681 fn from ( v : NotNan < f32 > ) -> NotNan < f64 > {
668682 unsafe {
669- NotNan :: unchecked_new ( v. 0 as f64 )
683+ NotNan :: new_unchecked ( v. 0 as f64 )
670684 }
671685 }
672686}
@@ -1246,9 +1260,9 @@ mod impl_rand {
12461260 impl Distribution <NotNan <$f>> for $dist {
12471261 fn sample<R : Rng + ?Sized >( & self , rng: & mut R ) -> NotNan <$f> {
12481262 // 'rand' never generates NaN values in the Standard, Open01, or
1249- // OpenClosed01 distributions. Using 'unchecked_new ' is therefore
1263+ // OpenClosed01 distributions. Using 'new_unchecked ' is therefore
12501264 // safe.
1251- unsafe { NotNan :: unchecked_new ( self . sample( rng) ) }
1265+ unsafe { NotNan :: new_unchecked ( self . sample( rng) ) }
12521266 }
12531267 }
12541268
@@ -1299,7 +1313,7 @@ mod impl_rand {
12991313 }
13001314 fn sample<R : Rng + ?Sized >( & self , rng: & mut R ) -> Self :: X {
13011315 // UniformFloat.sample() will never return NaN.
1302- unsafe { NotNan :: unchecked_new ( self . 0 . sample( rng) ) }
1316+ unsafe { NotNan :: new_unchecked ( self . 0 . sample( rng) ) }
13031317 }
13041318 }
13051319
0 commit comments