@@ -666,8 +666,9 @@ impl f64 {
666
666
///
667
667
/// ```
668
668
#[ stable( feature = "float_bits_conv" , since = "1.20.0" ) ]
669
+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
669
670
#[ inline]
670
- pub fn to_bits ( self ) -> u64 {
671
+ pub const fn to_bits ( self ) -> u64 {
671
672
// SAFETY: `u64` is a plain old datatype so we can always transmute to it
672
673
unsafe { mem:: transmute ( self ) }
673
674
}
@@ -709,8 +710,9 @@ impl f64 {
709
710
/// assert_eq!(v, 12.5);
710
711
/// ```
711
712
#[ stable( feature = "float_bits_conv" , since = "1.20.0" ) ]
713
+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
712
714
#[ inline]
713
- pub fn from_bits ( v : u64 ) -> Self {
715
+ pub const fn from_bits ( v : u64 ) -> Self {
714
716
// SAFETY: `u64` is a plain old datatype so we can always transmute from it
715
717
// It turns out the safety issues with sNaN were overblown! Hooray!
716
718
unsafe { mem:: transmute ( v) }
@@ -726,8 +728,9 @@ impl f64 {
726
728
/// assert_eq!(bytes, [0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
727
729
/// ```
728
730
#[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
731
+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
729
732
#[ inline]
730
- pub fn to_be_bytes ( self ) -> [ u8 ; 8 ] {
733
+ pub const fn to_be_bytes ( self ) -> [ u8 ; 8 ] {
731
734
self . to_bits ( ) . to_be_bytes ( )
732
735
}
733
736
@@ -741,8 +744,9 @@ impl f64 {
741
744
/// assert_eq!(bytes, [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x40]);
742
745
/// ```
743
746
#[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
747
+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
744
748
#[ inline]
745
- pub fn to_le_bytes ( self ) -> [ u8 ; 8 ] {
749
+ pub const fn to_le_bytes ( self ) -> [ u8 ; 8 ] {
746
750
self . to_bits ( ) . to_le_bytes ( )
747
751
}
748
752
@@ -769,8 +773,9 @@ impl f64 {
769
773
/// );
770
774
/// ```
771
775
#[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
776
+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
772
777
#[ inline]
773
- pub fn to_ne_bytes ( self ) -> [ u8 ; 8 ] {
778
+ pub const fn to_ne_bytes ( self ) -> [ u8 ; 8 ] {
774
779
self . to_bits ( ) . to_ne_bytes ( )
775
780
}
776
781
@@ -783,8 +788,9 @@ impl f64 {
783
788
/// assert_eq!(value, 12.5);
784
789
/// ```
785
790
#[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
791
+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
786
792
#[ inline]
787
- pub fn from_be_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
793
+ pub const fn from_be_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
788
794
Self :: from_bits ( u64:: from_be_bytes ( bytes) )
789
795
}
790
796
@@ -797,8 +803,9 @@ impl f64 {
797
803
/// assert_eq!(value, 12.5);
798
804
/// ```
799
805
#[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
806
+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
800
807
#[ inline]
801
- pub fn from_le_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
808
+ pub const fn from_le_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
802
809
Self :: from_bits ( u64:: from_le_bytes ( bytes) )
803
810
}
804
811
@@ -822,8 +829,9 @@ impl f64 {
822
829
/// assert_eq!(value, 12.5);
823
830
/// ```
824
831
#[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
832
+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
825
833
#[ inline]
826
- pub fn from_ne_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
834
+ pub const fn from_ne_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
827
835
Self :: from_bits ( u64:: from_ne_bytes ( bytes) )
828
836
}
829
837
0 commit comments