Skip to content

doc: Insert examples with universal function call syntax #36248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/libstd/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -1018,23 +1020,20 @@ 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);
/// assert!(abs_difference_1 <= std::f32::EPSILON);
/// assert!(abs_difference_2 <= std::f32::EPSILON);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down
17 changes: 8 additions & 9 deletions src/libstd/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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);
Expand Down