From 7b72c2831c6a50a9e07a3d94ebef5d9f29bfd51e Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 31 Oct 2019 16:13:28 +0000 Subject: [PATCH] Stabilize float_to_from_bytes feature --- src/libcore/num/f32.rs | 18 ++++++------------ src/libcore/num/f64.rs | 18 ++++++------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 22e7573eca65b..5730088c4d9a9 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -466,11 +466,10 @@ impl f32 { /// # Examples /// /// ``` - /// #![feature(float_to_from_bytes)] /// let bytes = 12.5f32.to_be_bytes(); /// assert_eq!(bytes, [0x41, 0x48, 0x00, 0x00]); /// ``` - #[unstable(feature = "float_to_from_bytes", issue = "60446")] + #[stable(feature = "float_to_from_bytes", since = "1.40.0")] #[inline] pub fn to_be_bytes(self) -> [u8; 4] { self.to_bits().to_be_bytes() @@ -482,11 +481,10 @@ impl f32 { /// # Examples /// /// ``` - /// #![feature(float_to_from_bytes)] /// let bytes = 12.5f32.to_le_bytes(); /// assert_eq!(bytes, [0x00, 0x00, 0x48, 0x41]); /// ``` - #[unstable(feature = "float_to_from_bytes", issue = "60446")] + #[stable(feature = "float_to_from_bytes", since = "1.40.0")] #[inline] pub fn to_le_bytes(self) -> [u8; 4] { self.to_bits().to_le_bytes() @@ -504,7 +502,6 @@ impl f32 { /// # Examples /// /// ``` - /// #![feature(float_to_from_bytes)] /// let bytes = 12.5f32.to_ne_bytes(); /// assert_eq!( /// bytes, @@ -515,7 +512,7 @@ impl f32 { /// } /// ); /// ``` - #[unstable(feature = "float_to_from_bytes", issue = "60446")] + #[stable(feature = "float_to_from_bytes", since = "1.40.0")] #[inline] pub fn to_ne_bytes(self) -> [u8; 4] { self.to_bits().to_ne_bytes() @@ -526,11 +523,10 @@ impl f32 { /// # Examples /// /// ``` - /// #![feature(float_to_from_bytes)] /// let value = f32::from_be_bytes([0x41, 0x48, 0x00, 0x00]); /// assert_eq!(value, 12.5); /// ``` - #[unstable(feature = "float_to_from_bytes", issue = "60446")] + #[stable(feature = "float_to_from_bytes", since = "1.40.0")] #[inline] pub fn from_be_bytes(bytes: [u8; 4]) -> Self { Self::from_bits(u32::from_be_bytes(bytes)) @@ -541,11 +537,10 @@ impl f32 { /// # Examples /// /// ``` - /// #![feature(float_to_from_bytes)] /// let value = f32::from_le_bytes([0x00, 0x00, 0x48, 0x41]); /// assert_eq!(value, 12.5); /// ``` - #[unstable(feature = "float_to_from_bytes", issue = "60446")] + #[stable(feature = "float_to_from_bytes", since = "1.40.0")] #[inline] pub fn from_le_bytes(bytes: [u8; 4]) -> Self { Self::from_bits(u32::from_le_bytes(bytes)) @@ -563,7 +558,6 @@ impl f32 { /// # Examples /// /// ``` - /// #![feature(float_to_from_bytes)] /// let value = f32::from_ne_bytes(if cfg!(target_endian = "big") { /// [0x41, 0x48, 0x00, 0x00] /// } else { @@ -571,7 +565,7 @@ impl f32 { /// }); /// assert_eq!(value, 12.5); /// ``` - #[unstable(feature = "float_to_from_bytes", issue = "60446")] + #[stable(feature = "float_to_from_bytes", since = "1.40.0")] #[inline] pub fn from_ne_bytes(bytes: [u8; 4]) -> Self { Self::from_bits(u32::from_ne_bytes(bytes)) diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index bbe1d04078060..2bdeda340dce0 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -479,11 +479,10 @@ impl f64 { /// # Examples /// /// ``` - /// #![feature(float_to_from_bytes)] /// let bytes = 12.5f64.to_be_bytes(); /// assert_eq!(bytes, [0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); /// ``` - #[unstable(feature = "float_to_from_bytes", issue = "60446")] + #[stable(feature = "float_to_from_bytes", since = "1.40.0")] #[inline] pub fn to_be_bytes(self) -> [u8; 8] { self.to_bits().to_be_bytes() @@ -495,11 +494,10 @@ impl f64 { /// # Examples /// /// ``` - /// #![feature(float_to_from_bytes)] /// let bytes = 12.5f64.to_le_bytes(); /// assert_eq!(bytes, [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x40]); /// ``` - #[unstable(feature = "float_to_from_bytes", issue = "60446")] + #[stable(feature = "float_to_from_bytes", since = "1.40.0")] #[inline] pub fn to_le_bytes(self) -> [u8; 8] { self.to_bits().to_le_bytes() @@ -517,7 +515,6 @@ impl f64 { /// # Examples /// /// ``` - /// #![feature(float_to_from_bytes)] /// let bytes = 12.5f64.to_ne_bytes(); /// assert_eq!( /// bytes, @@ -528,7 +525,7 @@ impl f64 { /// } /// ); /// ``` - #[unstable(feature = "float_to_from_bytes", issue = "60446")] + #[stable(feature = "float_to_from_bytes", since = "1.40.0")] #[inline] pub fn to_ne_bytes(self) -> [u8; 8] { self.to_bits().to_ne_bytes() @@ -539,11 +536,10 @@ impl f64 { /// # Examples /// /// ``` - /// #![feature(float_to_from_bytes)] /// let value = f64::from_be_bytes([0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); /// assert_eq!(value, 12.5); /// ``` - #[unstable(feature = "float_to_from_bytes", issue = "60446")] + #[stable(feature = "float_to_from_bytes", since = "1.40.0")] #[inline] pub fn from_be_bytes(bytes: [u8; 8]) -> Self { Self::from_bits(u64::from_be_bytes(bytes)) @@ -554,11 +550,10 @@ impl f64 { /// # Examples /// /// ``` - /// #![feature(float_to_from_bytes)] /// let value = f64::from_le_bytes([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x40]); /// assert_eq!(value, 12.5); /// ``` - #[unstable(feature = "float_to_from_bytes", issue = "60446")] + #[stable(feature = "float_to_from_bytes", since = "1.40.0")] #[inline] pub fn from_le_bytes(bytes: [u8; 8]) -> Self { Self::from_bits(u64::from_le_bytes(bytes)) @@ -576,7 +571,6 @@ impl f64 { /// # Examples /// /// ``` - /// #![feature(float_to_from_bytes)] /// let value = f64::from_ne_bytes(if cfg!(target_endian = "big") { /// [0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] /// } else { @@ -584,7 +578,7 @@ impl f64 { /// }); /// assert_eq!(value, 12.5); /// ``` - #[unstable(feature = "float_to_from_bytes", issue = "60446")] + #[stable(feature = "float_to_from_bytes", since = "1.40.0")] #[inline] pub fn from_ne_bytes(bytes: [u8; 8]) -> Self { Self::from_bits(u64::from_ne_bytes(bytes))