Skip to content

Commit 269eeea

Browse files
authored
Rollup merge of rust-lang#70782 - faern:use-assoc-float-consts, r=dtolnay
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
2 parents 618ba73 + 28c9231 commit 269eeea

File tree

5 files changed

+34
-150
lines changed

5 files changed

+34
-150
lines changed

src/libcore/num/f32.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,7 @@ impl f32 {
394394
/// Converts radians to degrees.
395395
///
396396
/// ```
397-
/// use std::f32::consts;
398-
///
399-
/// let angle = consts::PI;
397+
/// let angle = std::f32::consts::PI;
400398
///
401399
/// let abs_difference = (angle.to_degrees() - 180.0).abs();
402400
///
@@ -413,11 +411,9 @@ impl f32 {
413411
/// Converts degrees to radians.
414412
///
415413
/// ```
416-
/// use std::f32::consts;
417-
///
418414
/// let angle = 180.0f32;
419415
///
420-
/// let abs_difference = (angle.to_radians() - consts::PI).abs();
416+
/// let abs_difference = (angle.to_radians() - std::f32::consts::PI).abs();
421417
///
422418
/// assert!(abs_difference <= f32::EPSILON);
423419
/// ```

src/libcore/num/f64.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,7 @@ impl f64 {
407407
/// Converts radians to degrees.
408408
///
409409
/// ```
410-
/// use std::f64::consts;
411-
///
412-
/// let angle = consts::PI;
410+
/// let angle = std::f64::consts::PI;
413411
///
414412
/// let abs_difference = (angle.to_degrees() - 180.0).abs();
415413
///
@@ -427,11 +425,9 @@ impl f64 {
427425
/// Converts degrees to radians.
428426
///
429427
/// ```
430-
/// use std::f64::consts;
431-
///
432428
/// let angle = 180.0_f64;
433429
///
434-
/// let abs_difference = (angle.to_radians() - consts::PI).abs();
430+
/// let abs_difference = (angle.to_radians() - std::f64::consts::PI).abs();
435431
///
436432
/// assert!(abs_difference < 1e-10);
437433
/// ```

src/libcore/ops/range.rs

-12
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
9898
/// # Examples
9999
///
100100
/// ```
101-
/// use std::f32;
102-
///
103101
/// assert!(!(3..5).contains(&2));
104102
/// assert!( (3..5).contains(&3));
105103
/// assert!( (3..5).contains(&4));
@@ -198,8 +196,6 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
198196
/// # Examples
199197
///
200198
/// ```
201-
/// use std::f32;
202-
///
203199
/// assert!(!(3..).contains(&2));
204200
/// assert!( (3..).contains(&3));
205201
/// assert!( (3..).contains(&1_000_000_000));
@@ -282,8 +278,6 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
282278
/// # Examples
283279
///
284280
/// ```
285-
/// use std::f32;
286-
///
287281
/// assert!( (..5).contains(&-1_000_000_000));
288282
/// assert!( (..5).contains(&4));
289283
/// assert!(!(..5).contains(&5));
@@ -453,8 +447,6 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
453447
/// # Examples
454448
///
455449
/// ```
456-
/// use std::f32;
457-
///
458450
/// assert!(!(3..=5).contains(&2));
459451
/// assert!( (3..=5).contains(&3));
460452
/// assert!( (3..=5).contains(&4));
@@ -581,8 +573,6 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
581573
/// # Examples
582574
///
583575
/// ```
584-
/// use std::f32;
585-
///
586576
/// assert!( (..=5).contains(&-1_000_000_000));
587577
/// assert!( (..=5).contains(&5));
588578
/// assert!(!(..=5).contains(&6));
@@ -721,8 +711,6 @@ pub trait RangeBounds<T: ?Sized> {
721711
/// # Examples
722712
///
723713
/// ```
724-
/// use std::f32;
725-
///
726714
/// assert!( (3..5).contains(&4));
727715
/// assert!(!(3..5).contains(&2));
728716
///

0 commit comments

Comments
 (0)