Skip to content

Commit

Permalink
Rollup merge of rust-lang#70782 - faern:use-assoc-float-consts, r=dto…
Browse files Browse the repository at this point in the history
…lnay

Stop importing the float modules in documentation

Follow up to rust-lang#69860. I realized I had not searched for and fixed this for the float values. So with this PR they also use the associated constants instead of the module level constants.

For the documentation where it also was using the `consts` submodule I opted to change it to import that directly. This becomes more in line with how other docs that use the `consts` submodule looks. And it also makes it so there are not two `f32` or `f64` things in the current namespace (both the module and the primitive type) and then hopefully confusing documentation readers less.

r? @dtolnay
  • Loading branch information
Centril authored Apr 5, 2020
2 parents 618ba73 + 28c9231 commit 269eeea
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 150 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
12 changes: 0 additions & 12 deletions src/libcore/ops/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
/// # Examples
///
/// ```
/// use std::f32;
///
/// assert!(!(3..5).contains(&2));
/// assert!( (3..5).contains(&3));
/// assert!( (3..5).contains(&4));
Expand Down Expand Up @@ -198,8 +196,6 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
/// # Examples
///
/// ```
/// use std::f32;
///
/// assert!(!(3..).contains(&2));
/// assert!( (3..).contains(&3));
/// assert!( (3..).contains(&1_000_000_000));
Expand Down Expand Up @@ -282,8 +278,6 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
/// # Examples
///
/// ```
/// use std::f32;
///
/// assert!( (..5).contains(&-1_000_000_000));
/// assert!( (..5).contains(&4));
/// assert!(!(..5).contains(&5));
Expand Down Expand Up @@ -453,8 +447,6 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// # Examples
///
/// ```
/// use std::f32;
///
/// assert!(!(3..=5).contains(&2));
/// assert!( (3..=5).contains(&3));
/// assert!( (3..=5).contains(&4));
Expand Down Expand Up @@ -581,8 +573,6 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
/// # Examples
///
/// ```
/// use std::f32;
///
/// assert!( (..=5).contains(&-1_000_000_000));
/// assert!( (..=5).contains(&5));
/// assert!(!(..=5).contains(&6));
Expand Down Expand Up @@ -721,8 +711,6 @@ pub trait RangeBounds<T: ?Sized> {
/// # Examples
///
/// ```
/// use std::f32;
///
/// assert!( (3..5).contains(&4));
/// assert!(!(3..5).contains(&2));
///
Expand Down
Loading

0 comments on commit 269eeea

Please sign in to comment.