@@ -17,7 +17,9 @@ use alloc::collections::BTreeSet;
17
17
#[ cfg( feature = "std" ) ] use std:: collections:: HashSet ;
18
18
19
19
#[ cfg( feature = "alloc" ) ]
20
- use crate :: distributions:: { uniform:: SampleUniform , Distribution , Uniform , WeightedError } ;
20
+ use crate :: distributions:: { uniform:: SampleUniform , Distribution , Uniform } ;
21
+ #[ cfg( feature = "std" ) ]
22
+ use crate :: distributions:: WeightedError ;
21
23
use crate :: Rng ;
22
24
23
25
#[ cfg( feature = "serde1" ) ]
@@ -270,6 +272,8 @@ where R: Rng + ?Sized {
270
272
/// `O(length + amount * log length)` time otherwise.
271
273
///
272
274
/// Panics if `amount > length`.
275
+ #[ cfg( feature = "std" ) ]
276
+ #[ cfg_attr( doc_cfg, doc( cfg( feature = "std" ) ) ) ]
273
277
pub fn sample_weighted < R , F , X > (
274
278
rng : & mut R , length : usize , weight : F , amount : usize ,
275
279
) -> Result < IndexVec , WeightedError >
@@ -301,6 +305,7 @@ where
301
305
/// + amount * log length)` time otherwise.
302
306
///
303
307
/// Panics if `amount > length`.
308
+ #[ cfg( feature = "std" ) ]
304
309
fn sample_efraimidis_spirakis < R , F , X , N > (
305
310
rng : & mut R , length : N , weight : F , amount : N ,
306
311
) -> Result < IndexVec , WeightedError >
@@ -375,9 +380,6 @@ where
375
380
376
381
#[ cfg( not( feature = "nightly" ) ) ]
377
382
{
378
- #[ cfg( all( feature = "alloc" , not( feature = "std" ) ) ) ]
379
- use crate :: alloc:: collections:: BinaryHeap ;
380
- #[ cfg( feature = "std" ) ]
381
383
use std:: collections:: BinaryHeap ;
382
384
383
385
// Partially sort the array such that the `amount` elements with the largest
@@ -619,6 +621,7 @@ mod test {
619
621
assert_eq ! ( v1, v2) ;
620
622
}
621
623
624
+ #[ cfg( feature = "std" ) ]
622
625
#[ test]
623
626
fn test_sample_weighted ( ) {
624
627
let seed_rng = crate :: test:: rng;
0 commit comments