@@ -87,13 +87,13 @@ pub trait IndexedRandom: Index<usize> {
87
87
/// }
88
88
/// ```
89
89
#[ cfg( feature = "alloc" ) ]
90
- fn sample < R > ( & self , rng : & mut R , amount : usize ) -> SliceChooseIter < Self , Self :: Output >
90
+ fn sample < R > ( & self , rng : & mut R , amount : usize ) -> IndexedSamples < Self , Self :: Output >
91
91
where
92
92
Self :: Output : Sized ,
93
93
R : Rng + ?Sized ,
94
94
{
95
95
let amount = core:: cmp:: min ( amount, self . len ( ) ) ;
96
- SliceChooseIter {
96
+ IndexedSamples {
97
97
slice : self ,
98
98
_phantom : Default :: default ( ) ,
99
99
indices : index:: sample ( rng, self . len ( ) , amount) . into_iter ( ) ,
@@ -209,15 +209,15 @@ pub trait IndexedRandom: Index<usize> {
209
209
rng : & mut R ,
210
210
amount : usize ,
211
211
weight : F ,
212
- ) -> Result < SliceChooseIter < Self , Self :: Output > , WeightError >
212
+ ) -> Result < IndexedSamples < Self , Self :: Output > , WeightError >
213
213
where
214
214
Self :: Output : Sized ,
215
215
R : Rng + ?Sized ,
216
216
F : Fn ( & Self :: Output ) -> X ,
217
217
X : Into < f64 > ,
218
218
{
219
219
let amount = core:: cmp:: min ( amount, self . len ( ) ) ;
220
- Ok ( SliceChooseIter {
220
+ Ok ( IndexedSamples {
221
221
slice : self ,
222
222
_phantom : Default :: default ( ) ,
223
223
indices : index:: sample_weighted (
@@ -233,7 +233,7 @@ pub trait IndexedRandom: Index<usize> {
233
233
/// Deprecated: use [`Self::sample`] instead
234
234
#[ cfg( feature = "alloc" ) ]
235
235
#[ deprecated( since = "0.9.2" , note = "Renamed to `sample`" ) ]
236
- fn choose_multiple < R > ( & self , rng : & mut R , amount : usize ) -> SliceChooseIter < Self , Self :: Output >
236
+ fn choose_multiple < R > ( & self , rng : & mut R , amount : usize ) -> IndexedSamples < Self , Self :: Output >
237
237
where
238
238
Self :: Output : Sized ,
239
239
R : Rng + ?Sized ,
@@ -259,7 +259,7 @@ pub trait IndexedRandom: Index<usize> {
259
259
rng : & mut R ,
260
260
amount : usize ,
261
261
weight : F ,
262
- ) -> Result < SliceChooseIter < Self , Self :: Output > , WeightError >
262
+ ) -> Result < IndexedSamples < Self , Self :: Output > , WeightError >
263
263
where
264
264
Self :: Output : Sized ,
265
265
R : Rng + ?Sized ,
@@ -454,14 +454,14 @@ impl<T> SliceRandom for [T] {
454
454
/// [`IndexedRandom::sample`](trait.IndexedRandom.html#tymethod.sample).
455
455
#[ cfg( feature = "alloc" ) ]
456
456
#[ derive( Debug ) ]
457
- pub struct SliceChooseIter < ' a , S : ?Sized + ' a , T : ' a > {
457
+ pub struct IndexedSamples < ' a , S : ?Sized + ' a , T : ' a > {
458
458
slice : & ' a S ,
459
459
_phantom : core:: marker:: PhantomData < T > ,
460
460
indices : index:: IndexVecIntoIter ,
461
461
}
462
462
463
463
#[ cfg( feature = "alloc" ) ]
464
- impl < ' a , S : Index < usize , Output = T > + ?Sized + ' a , T : ' a > Iterator for SliceChooseIter < ' a , S , T > {
464
+ impl < ' a , S : Index < usize , Output = T > + ?Sized + ' a , T : ' a > Iterator for IndexedSamples < ' a , S , T > {
465
465
type Item = & ' a T ;
466
466
467
467
fn next ( & mut self ) -> Option < Self :: Item > {
@@ -476,13 +476,18 @@ impl<'a, S: Index<usize, Output = T> + ?Sized + 'a, T: 'a> Iterator for SliceCho
476
476
477
477
#[ cfg( feature = "alloc" ) ]
478
478
impl < ' a , S : Index < usize , Output = T > + ?Sized + ' a , T : ' a > ExactSizeIterator
479
- for SliceChooseIter < ' a , S , T >
479
+ for IndexedSamples < ' a , S , T >
480
480
{
481
481
fn len ( & self ) -> usize {
482
482
self . indices . len ( )
483
483
}
484
484
}
485
485
486
+ /// Deprecated: renamed to [`IndexedSamples`]
487
+ #[ cfg( feature = "alloc" ) ]
488
+ #[ deprecated( since = "0.9.2" , note = "Renamed to `IndexedSamples`" ) ]
489
+ pub type SliceChooseIter < ' a , S , T > = IndexedSamples < ' a , S , T > ;
490
+
486
491
#[ cfg( test) ]
487
492
mod test {
488
493
use super :: * ;
0 commit comments