Skip to content

Commit

Permalink
Make libcore float constant examples similar to libstd
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Apr 5, 2020
1 parent daf8afd commit 28c9231
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 2 additions & 6 deletions src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,7 @@ impl f32 {
/// Converts radians to degrees.
///
/// ```
/// use std::f32::consts;
///
/// let angle = consts::PI;
/// let angle = std::f32::consts::PI;
///
/// let abs_difference = (angle.to_degrees() - 180.0).abs();
///
Expand All @@ -413,11 +411,9 @@ impl f32 {
/// Converts degrees to radians.
///
/// ```
/// use std::f32::consts;
///
/// let angle = 180.0f32;
///
/// let abs_difference = (angle.to_radians() - consts::PI).abs();
/// let abs_difference = (angle.to_radians() - std::f32::consts::PI).abs();
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
Expand Down
8 changes: 2 additions & 6 deletions src/libcore/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,7 @@ impl f64 {
/// Converts radians to degrees.
///
/// ```
/// use std::f64::consts;
///
/// let angle = consts::PI;
/// let angle = std::f64::consts::PI;
///
/// let abs_difference = (angle.to_degrees() - 180.0).abs();
///
Expand All @@ -427,11 +425,9 @@ impl f64 {
/// Converts degrees to radians.
///
/// ```
/// use std::f64::consts;
///
/// let angle = 180.0_f64;
///
/// let abs_difference = (angle.to_radians() - consts::PI).abs();
/// let abs_difference = (angle.to_radians() - std::f64::consts::PI).abs();
///
/// assert!(abs_difference < 1e-10);
/// ```
Expand Down

0 comments on commit 28c9231

Please sign in to comment.