@@ -53,29 +53,29 @@ use distributions::float::IntoFloat;
53
53
/// ```
54
54
#[ derive( Clone , Copy , Debug ) ]
55
55
pub struct Range < X : SampleRange > {
56
- inner : X :: T ,
56
+ inner : X :: Impl ,
57
57
}
58
58
59
59
impl < X : SampleRange > Range < X > {
60
60
/// Create a new `Range` instance which samples uniformly from the half
61
61
/// open range `[low, high)` (excluding `high`). Panics if `low >= high`.
62
62
pub fn new ( low : X , high : X ) -> Range < X > {
63
63
assert ! ( low < high, "Range::new called with `low >= high`" ) ;
64
- Range { inner : X :: T :: new ( low, high) }
64
+ Range { inner : X :: Impl :: new ( low, high) }
65
65
}
66
66
67
67
/// Create a new `Range` instance which samples uniformly from the closed
68
68
/// range `[low, high]` (inclusive). Panics if `low >= high`.
69
69
pub fn new_inclusive ( low : X , high : X ) -> Range < X > {
70
70
assert ! ( low < high, "Range::new called with `low >= high`" ) ;
71
- Range { inner : X :: T :: new_inclusive ( low, high) }
71
+ Range { inner : X :: Impl :: new_inclusive ( low, high) }
72
72
}
73
73
74
74
/// Sample a single value uniformly from `[low, high)`.
75
75
/// Panics if `low >= high`.
76
76
pub fn sample_single < R : Rng + ?Sized > ( low : X , high : X , rng : & mut R ) -> X {
77
77
assert ! ( low < high, "Range::sample_single called with low >= high" ) ;
78
- X :: T :: sample_single ( low, high, rng)
78
+ X :: Impl :: sample_single ( low, high, rng)
79
79
}
80
80
}
81
81
@@ -88,8 +88,8 @@ impl<X: SampleRange> Distribution<X> for Range<X> {
88
88
/// Helper trait for creating objects using the correct implementation of
89
89
/// `RangeImpl` for the sampling type; this enables `Range::new(a, b)` to work.
90
90
pub trait SampleRange : PartialOrd +Sized {
91
- /// Actual `RangeImpl` implementation for `X`.
92
- type T : RangeImpl < X = Self > ;
91
+ /// The `RangeImpl` implementation supporting type `X`.
92
+ type Impl : RangeImpl < X = Self > ;
93
93
}
94
94
95
95
/// Helper trait handling actual range sampling.
@@ -125,7 +125,7 @@ pub trait SampleRange: PartialOrd+Sized {
125
125
/// }
126
126
///
127
127
/// impl SampleRange for MyF32 {
128
- /// type T = RangeMyF32;
128
+ /// type Impl = RangeMyF32;
129
129
/// }
130
130
///
131
131
/// let (low, high) = (MyF32(17.0f32), MyF32(22.0f32));
@@ -184,7 +184,7 @@ macro_rules! range_int_impl {
184
184
( $ty: ty, $signed: ty, $unsigned: ident,
185
185
$i_large: ident, $u_large: ident) => {
186
186
impl SampleRange for $ty {
187
- type T = RangeInt <$ty>;
187
+ type Impl = RangeInt <$ty>;
188
188
}
189
189
190
190
impl RangeImpl for RangeInt <$ty> {
@@ -429,7 +429,7 @@ pub struct RangeFloat<X> {
429
429
macro_rules! range_float_impl {
430
430
( $ty: ty, $bits_to_discard: expr, $next_u: ident) => {
431
431
impl SampleRange for $ty {
432
- type T = RangeFloat <$ty>;
432
+ type Impl = RangeFloat <$ty>;
433
433
}
434
434
435
435
impl RangeImpl for RangeFloat <$ty> {
@@ -567,7 +567,7 @@ mod tests {
567
567
}
568
568
}
569
569
impl SampleRange for MyF32 {
570
- type T = RangeMyF32 ;
570
+ type Impl = RangeMyF32 ;
571
571
}
572
572
573
573
let ( low, high) = ( MyF32 { x : 17.0f32 } , MyF32 { x : 22.0f32 } ) ;
0 commit comments