242242 html_root_url = "https://doc.rust-lang.org/rand/" ) ]
243243
244244#![ cfg_attr( feature="no_std" , no_std) ]
245- #![ cfg_attr( feature="no_std" , feature( alloc, collections) ) ]
245+ #![ cfg_attr( feature="box" , feature( alloc) ) ]
246+ #![ cfg_attr( feature="vec" , feature( collections) ) ]
246247
247248#[ cfg( test) ] #[ macro_use] extern crate log;
248249
249250#[ cfg( not( feature="no_std" ) ) ] extern crate std as core;
250- #[ cfg( feature="no_std " ) ] extern crate core_io as io;
251- #[ cfg( feature="no_std " ) ] extern crate alloc;
252- #[ cfg( feature="no_std " ) ] extern crate collections;
251+ #[ cfg( feature="core_io " ) ] extern crate core_io as io;
252+ #[ cfg( feature="box " ) ] extern crate alloc;
253+ #[ cfg( feature="vec " ) ] extern crate collections;
253254
254255#[ cfg( not( feature="no_std" ) ) ] use core:: cell:: RefCell ;
255256use core:: marker;
256257use core:: mem;
257258#[ cfg( not( feature="no_std" ) ) ] use std:: io;
258259#[ cfg( not( feature="no_std" ) ) ] use std:: rc:: Rc ;
259260use core:: num:: Wrapping as w;
260- #[ cfg( feature="no_std " ) ] use alloc:: boxed:: Box ;
261- #[ cfg( feature="no_std " ) ] use collections:: vec:: Vec ;
261+ #[ cfg( feature="box " ) ] use alloc:: boxed:: Box ;
262+ #[ cfg( feature="vec " ) ] use collections:: vec:: Vec ;
262263
263264#[ cfg( not( feature="no_std" ) ) ] pub use os:: OsRng ;
264265
@@ -279,7 +280,7 @@ pub mod chacha;
279280pub mod reseeding;
280281mod rand_impls;
281282#[ cfg( not( feature="no_std" ) ) ] pub mod os;
282- pub mod read;
283+ # [ cfg ( any ( not ( feature= "no_std" ) , feature= "core_io" ) ) ] pub mod read;
283284
284285#[ allow( bad_style) ]
285286type w64 = w < u64 > ;
@@ -586,6 +587,7 @@ impl<'a, R: ?Sized> Rng for &'a mut R where R: Rng {
586587 }
587588}
588589
590+ #[ cfg( any( feature="box" , not( feature="no_std" ) ) ) ]
589591impl < R : ?Sized > Rng for Box < R > where R : Rng {
590592 fn next_u32 ( & mut self ) -> u32 {
591593 ( * * self ) . next_u32 ( )
@@ -989,6 +991,7 @@ pub fn random<T: Rand>() -> T {
989991/// let sample = sample(&mut rng, 1..100, 5);
990992/// println!("{:?}", sample);
991993/// ```
994+ #[ cfg( any( feature="vec" , not( feature="no_std" ) ) ) ]
992995pub fn sample < T , I , R > ( rng : & mut R , iterable : I , amount : usize ) -> Vec < T >
993996 where I : IntoIterator < Item =T > ,
994997 R : Rng ,
0 commit comments