@@ -666,8 +666,9 @@ impl f64 {
666666 ///
667667 /// ```
668668 #[ stable( feature = "float_bits_conv" , since = "1.20.0" ) ]
669+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
669670 #[ inline]
670- pub fn to_bits ( self ) -> u64 {
671+ pub const fn to_bits ( self ) -> u64 {
671672 // SAFETY: `u64` is a plain old datatype so we can always transmute to it
672673 unsafe { mem:: transmute ( self ) }
673674 }
@@ -709,8 +710,9 @@ impl f64 {
709710 /// assert_eq!(v, 12.5);
710711 /// ```
711712 #[ stable( feature = "float_bits_conv" , since = "1.20.0" ) ]
713+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
712714 #[ inline]
713- pub fn from_bits ( v : u64 ) -> Self {
715+ pub const fn from_bits ( v : u64 ) -> Self {
714716 // SAFETY: `u64` is a plain old datatype so we can always transmute from it
715717 // It turns out the safety issues with sNaN were overblown! Hooray!
716718 unsafe { mem:: transmute ( v) }
@@ -726,8 +728,9 @@ impl f64 {
726728 /// assert_eq!(bytes, [0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
727729 /// ```
728730 #[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
731+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
729732 #[ inline]
730- pub fn to_be_bytes ( self ) -> [ u8 ; 8 ] {
733+ pub const fn to_be_bytes ( self ) -> [ u8 ; 8 ] {
731734 self . to_bits ( ) . to_be_bytes ( )
732735 }
733736
@@ -741,8 +744,9 @@ impl f64 {
741744 /// assert_eq!(bytes, [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x40]);
742745 /// ```
743746 #[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
747+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
744748 #[ inline]
745- pub fn to_le_bytes ( self ) -> [ u8 ; 8 ] {
749+ pub const fn to_le_bytes ( self ) -> [ u8 ; 8 ] {
746750 self . to_bits ( ) . to_le_bytes ( )
747751 }
748752
@@ -769,8 +773,9 @@ impl f64 {
769773 /// );
770774 /// ```
771775 #[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
776+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
772777 #[ inline]
773- pub fn to_ne_bytes ( self ) -> [ u8 ; 8 ] {
778+ pub const fn to_ne_bytes ( self ) -> [ u8 ; 8 ] {
774779 self . to_bits ( ) . to_ne_bytes ( )
775780 }
776781
@@ -783,8 +788,9 @@ impl f64 {
783788 /// assert_eq!(value, 12.5);
784789 /// ```
785790 #[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
791+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
786792 #[ inline]
787- pub fn from_be_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
793+ pub const fn from_be_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
788794 Self :: from_bits ( u64:: from_be_bytes ( bytes) )
789795 }
790796
@@ -797,8 +803,9 @@ impl f64 {
797803 /// assert_eq!(value, 12.5);
798804 /// ```
799805 #[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
806+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
800807 #[ inline]
801- pub fn from_le_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
808+ pub const fn from_le_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
802809 Self :: from_bits ( u64:: from_le_bytes ( bytes) )
803810 }
804811
@@ -822,8 +829,9 @@ impl f64 {
822829 /// assert_eq!(value, 12.5);
823830 /// ```
824831 #[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
832+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
825833 #[ inline]
826- pub fn from_ne_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
834+ pub const fn from_ne_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
827835 Self :: from_bits ( u64:: from_ne_bytes ( bytes) )
828836 }
829837
0 commit comments