From 2d273f43ae3f0c7e8bb22e73180cf0ce9c3b042d Mon Sep 17 00:00:00 2001 From: Dirk Leifeld Date: Sat, 3 Sep 2016 20:44:22 +0200 Subject: [PATCH 1/2] Insert examples with universal function call syntax. --- src/libstd/num/f32.rs | 17 ++++++++--------- src/libstd/num/f64.rs | 17 ++++++++--------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 7a676c041ad89..f44579335ecc3 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -800,6 +800,7 @@ impl f32 { /// let y = 2.0f32; /// /// assert_eq!(x.max(y), y); + /// assert_eq!(f32::max(x,y), y); /// ``` /// /// If one of the arguments is NaN, then the other argument is returned. @@ -816,6 +817,7 @@ impl f32 { /// let y = 2.0f32; /// /// assert_eq!(x.min(y), x); + /// assert_eq!(f32::min(x,y), x); /// ``` /// /// If one of the arguments is NaN, then the other argument is returned. @@ -1018,20 +1020,17 @@ impl f32 { /// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)` /// /// ``` - /// use std::f32; - /// - /// let pi = f32::consts::PI; + /// let pi = std::f32::consts::PI; /// // All angles from horizontal right (+x) /// // 45 deg counter-clockwise - /// let x1 = 3.0f32; - /// let y1 = -3.0f32; + /// let point = (3.0f32, -3.0f32); /// /// // 135 deg clockwise - /// let x2 = -3.0f32; - /// let y2 = 3.0f32; + /// let x = -3.0f32; + /// let y = 3.0f32; /// - /// let abs_difference_1 = (y1.atan2(x1) - (-pi/4.0)).abs(); - /// let abs_difference_2 = (y2.atan2(x2) - 3.0*pi/4.0).abs(); + /// let abs_difference_1 = (f32::atan2(point.1, point.0) - (-pi/4.0)).abs(); + /// let abs_difference_2 = (y.atan2(x) - 3.0*pi/4.0).abs(); /// /// assert!(abs_difference_1 <= f32::EPSILON); /// assert!(abs_difference_2 <= f32::EPSILON); diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 67a1c302483d2..0788a7ddf2cb8 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -689,6 +689,7 @@ impl f64 { /// let y = 2.0_f64; /// /// assert_eq!(x.max(y), y); + /// assert_eq!(f64::max(x,y), y); /// ``` /// /// If one of the arguments is NaN, then the other argument is returned. @@ -705,6 +706,7 @@ impl f64 { /// let y = 2.0_f64; /// /// assert_eq!(x.min(y), x); + /// assert_eq!(f64::min(x,y), x); /// ``` /// /// If one of the arguments is NaN, then the other argument is returned. @@ -891,20 +893,17 @@ impl f64 { /// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)` /// /// ``` - /// use std::f64; - /// - /// let pi = f64::consts::PI; + /// let pi = std::f64::consts::PI; /// // All angles from horizontal right (+x) /// // 45 deg counter-clockwise - /// let x1 = 3.0_f64; - /// let y1 = -3.0_f64; + /// let point = (3.0_f64, -3.0_f64); /// /// // 135 deg clockwise - /// let x2 = -3.0_f64; - /// let y2 = 3.0_f64; + /// let x = -3.0_f64; + /// let y = 3.0_f64; /// - /// let abs_difference_1 = (y1.atan2(x1) - (-pi/4.0)).abs(); - /// let abs_difference_2 = (y2.atan2(x2) - 3.0*pi/4.0).abs(); + /// let abs_difference_1 = (f64::atan2(point.1, point.0) - (-pi/4.0)).abs(); + /// let abs_difference_2 = (y.atan2(x) - 3.0*pi/4.0).abs(); /// /// assert!(abs_difference_1 < 1e-10); /// assert!(abs_difference_2 < 1e-10); From f88a1f593f5322928bdd1346e269edaf6304d67b Mon Sep 17 00:00:00 2001 From: Dirk Leifeld Date: Sun, 4 Sep 2016 08:17:05 +0200 Subject: [PATCH 2/2] Add missing std prefix --- src/libstd/num/f32.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index f44579335ecc3..c3e378d439058 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -1032,8 +1032,8 @@ impl f32 { /// let abs_difference_1 = (f32::atan2(point.1, point.0) - (-pi/4.0)).abs(); /// let abs_difference_2 = (y.atan2(x) - 3.0*pi/4.0).abs(); /// - /// assert!(abs_difference_1 <= f32::EPSILON); - /// assert!(abs_difference_2 <= f32::EPSILON); + /// assert!(abs_difference_1 <= std::f32::EPSILON); + /// assert!(abs_difference_2 <= std::f32::EPSILON); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline]