@@ -664,8 +664,9 @@ impl f64 {
664664 ///
665665 /// ```
666666 #[ stable( feature = "float_bits_conv" , since = "1.20.0" ) ]
667+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
667668 #[ inline]
668- pub fn to_bits ( self ) -> u64 {
669+ pub const fn to_bits ( self ) -> u64 {
669670 // SAFETY: `u64` is a plain old datatype so we can always transmute to it
670671 unsafe { mem:: transmute ( self ) }
671672 }
@@ -707,8 +708,9 @@ impl f64 {
707708 /// assert_eq!(v, 12.5);
708709 /// ```
709710 #[ stable( feature = "float_bits_conv" , since = "1.20.0" ) ]
711+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
710712 #[ inline]
711- pub fn from_bits ( v : u64 ) -> Self {
713+ pub const fn from_bits ( v : u64 ) -> Self {
712714 // SAFETY: `u64` is a plain old datatype so we can always transmute from it
713715 // It turns out the safety issues with sNaN were overblown! Hooray!
714716 unsafe { mem:: transmute ( v) }
@@ -724,8 +726,9 @@ impl f64 {
724726 /// assert_eq!(bytes, [0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
725727 /// ```
726728 #[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
729+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
727730 #[ inline]
728- pub fn to_be_bytes ( self ) -> [ u8 ; 8 ] {
731+ pub const fn to_be_bytes ( self ) -> [ u8 ; 8 ] {
729732 self . to_bits ( ) . to_be_bytes ( )
730733 }
731734
@@ -739,8 +742,9 @@ impl f64 {
739742 /// assert_eq!(bytes, [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x40]);
740743 /// ```
741744 #[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
745+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
742746 #[ inline]
743- pub fn to_le_bytes ( self ) -> [ u8 ; 8 ] {
747+ pub const fn to_le_bytes ( self ) -> [ u8 ; 8 ] {
744748 self . to_bits ( ) . to_le_bytes ( )
745749 }
746750
@@ -767,8 +771,9 @@ impl f64 {
767771 /// );
768772 /// ```
769773 #[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
774+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
770775 #[ inline]
771- pub fn to_ne_bytes ( self ) -> [ u8 ; 8 ] {
776+ pub const fn to_ne_bytes ( self ) -> [ u8 ; 8 ] {
772777 self . to_bits ( ) . to_ne_bytes ( )
773778 }
774779
@@ -781,8 +786,9 @@ impl f64 {
781786 /// assert_eq!(value, 12.5);
782787 /// ```
783788 #[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
789+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
784790 #[ inline]
785- pub fn from_be_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
791+ pub const fn from_be_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
786792 Self :: from_bits ( u64:: from_be_bytes ( bytes) )
787793 }
788794
@@ -795,8 +801,9 @@ impl f64 {
795801 /// assert_eq!(value, 12.5);
796802 /// ```
797803 #[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
804+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
798805 #[ inline]
799- pub fn from_le_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
806+ pub const fn from_le_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
800807 Self :: from_bits ( u64:: from_le_bytes ( bytes) )
801808 }
802809
@@ -820,8 +827,9 @@ impl f64 {
820827 /// assert_eq!(value, 12.5);
821828 /// ```
822829 #[ stable( feature = "float_to_from_bytes" , since = "1.40.0" ) ]
830+ #[ rustc_const_unstable( feature = "const_float_bits_conv" , issue = "72447" ) ]
823831 #[ inline]
824- pub fn from_ne_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
832+ pub const fn from_ne_bytes ( bytes : [ u8 ; 8 ] ) -> Self {
825833 Self :: from_bits ( u64:: from_ne_bytes ( bytes) )
826834 }
827835}
0 commit comments