File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 111
111
use std:: time:: Duration ;
112
112
#[ cfg( not( feature = "std" ) ) ]
113
113
use core:: time:: Duration ;
114
- use core:: ops:: { Range , RangeInclusive } ;
114
+ use core:: ops:: { Range , RangeInclusive , RangeTo , RangeToInclusive } ;
115
115
116
116
use crate :: Rng ;
117
117
use crate :: distributions:: Distribution ;
@@ -306,6 +306,18 @@ impl<T: SampleUniform> Distribution<T> for RangeInclusive<T> {
306
306
}
307
307
}
308
308
309
+ impl Distribution < usize > for RangeTo < usize > {
310
+ fn sample < R : Rng + ?Sized > ( & self , rng : & mut R ) -> usize {
311
+ <usize as SampleUniform >:: Sampler :: sample_single ( 0 , self . end , rng)
312
+ }
313
+ }
314
+
315
+ impl Distribution < usize > for RangeToInclusive < usize > {
316
+ fn sample < R : Rng + ?Sized > ( & self , rng : & mut R ) -> usize {
317
+ <usize as SampleUniform >:: Sampler :: sample_single_inclusive ( 0 , self . end , rng)
318
+ }
319
+ }
320
+
309
321
/// Helper trait similar to [`Borrow`] but implemented
310
322
/// only for SampleUniform and references to SampleUniform in
311
323
/// order to resolve ambiguity issues.
You can’t perform that action at this time.
0 commit comments