Skip to content

Commit 316761d

Browse files
committed
Small cleanup
1 parent 8113b3e commit 316761d

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/distributions/uniform.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@
5959
//! use rand::distributions::uniform::{Uniform, SampleUniform};
6060
//! use rand::distributions::uniform::{UniformSampler, UniformFloat};
6161
//!
62-
//! #[derive(Clone, Copy, PartialEq, PartialOrd)]
6362
//! struct MyF32(f32);
6463
//!
6564
//! #[derive(Clone, Copy, Debug)]
6665
//! struct UniformMyF32 {
6766
//! inner: UniformFloat<f32>,
6867
//! }
68+
//!
6969
//! impl UniformSampler for UniformMyF32 {
7070
//! type X = MyF32;
7171
//! fn new(low: Self::X, high: Self::X) -> Self {
@@ -251,6 +251,17 @@ pub trait UniformSampler: Sized {
251251
}
252252
}
253253

254+
impl<X: SampleUniform> From<::core::ops::Range<X>> for Uniform<X> {
255+
fn from(r: ::core::ops::Range<X>) -> Uniform<X> {
256+
Uniform::new(r.start, r.end)
257+
}
258+
}
259+
260+
////////////////////////////////////////////////////////////////////////////////
261+
262+
// What follows are all back-ends.
263+
264+
254265
/// The back-end implementing [`UniformSampler`] for integer types.
255266
///
256267
/// Unless you are implementing [`UniformSampler`] for your own type, this type
@@ -406,12 +417,6 @@ macro_rules! uniform_int_impl {
406417
}
407418
}
408419

409-
impl<X: SampleUniform> From<::core::ops::Range<X>> for Uniform<X> {
410-
fn from(r: ::core::ops::Range<X>) -> Uniform<X> {
411-
Uniform::new(r.start, r.end)
412-
}
413-
}
414-
415420
uniform_int_impl! { i8, i8, u8, i32, u32 }
416421
uniform_int_impl! { i16, i16, u16, i32, u32 }
417422
uniform_int_impl! { i32, i32, u32, i32, u32 }
@@ -447,7 +452,6 @@ macro_rules! wmul_impl {
447452
}
448453
}
449454
}
450-
451455
wmul_impl! { u8, u16, 8 }
452456
wmul_impl! { u16, u32, 16 }
453457
wmul_impl! { u32, u64, 32 }
@@ -486,13 +490,11 @@ macro_rules! wmul_impl_large {
486490
}
487491
}
488492
}
489-
490493
#[cfg(not(feature = "i128_support"))]
491494
wmul_impl_large! { u64, 32 }
492495
#[cfg(feature = "i128_support")]
493496
wmul_impl_large! { u128, 64 }
494497

495-
496498
macro_rules! wmul_impl_usize {
497499
($ty:ty) => {
498500
impl WideningMultiply for usize {
@@ -506,7 +508,6 @@ macro_rules! wmul_impl_usize {
506508
}
507509
}
508510
}
509-
510511
#[cfg(target_pointer_width = "32")]
511512
wmul_impl_usize! { u32 }
512513
#[cfg(target_pointer_width = "64")]
@@ -607,7 +608,9 @@ macro_rules! uniform_float_impl {
607608
uniform_float_impl! { f32, 32 - 23, next_u32 }
608609
uniform_float_impl! { f64, 64 - 52, next_u64 }
609610

610-
/// Implementation of [`UniformSampler`] for `Duration`.
611+
612+
613+
/// The back-end implementing [`UniformSampler`] for `Duration`.
611614
///
612615
/// Unless you are implementing [`UniformSampler`] for your own types, this type
613616
/// should not be used directly, use [`Uniform`] instead.

0 commit comments

Comments
 (0)