File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -46,11 +46,16 @@ jobs:
46
46
- name : Install test runner for wasi
47
47
if : matrix.platform.target == 'wasm32-wasi'
48
48
run : curl https://wasmtime.dev/install.sh -sSf | bash
49
- - name : Stable Build
49
+ - name : Stable Build with all features
50
50
uses : actions-rs/cargo@v1
51
51
with :
52
52
command : build
53
53
args : --all-features --target ${{ matrix.platform.target }}
54
+ - name : Stable Build without features
55
+ uses : actions-rs/cargo@v1
56
+ with :
57
+ command : build
58
+ args : --target ${{ matrix.platform.target }}
54
59
- name : Tests
55
60
if : matrix.platform.target == 'x86_64-unknown-linux-gnu' || matrix.platform.target == 'x86_64-pc-windows-msvc' || matrix.platform.target == 'aarch64-apple-darwin'
56
61
uses : actions-rs/cargo@v1
Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ ndarray = { version = "0.15", optional = true }
26
26
num-traits = " 0.2.12"
27
27
num = " 0.4"
28
28
rand = { version = " 0.8.5" , default-features = false , features = [" small_rng" ] }
29
- getrandom = " *"
30
29
rand_distr = { version = " 0.4" , optional = true }
31
30
serde = { version = " 1" , features = [" derive" ], optional = true }
32
31
@@ -40,7 +39,7 @@ std_rand = ["rand/std_rng", "rand/std"]
40
39
js = [" getrandom/js" ]
41
40
42
41
[target .'cfg(target_arch = "wasm32")' .dependencies ]
43
- getrandom = { version = " *" , features = [ " js " ] }
42
+ getrandom = { version = " *" , optional = true }
44
43
45
44
[target .'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))' .dev-dependencies ]
46
45
wasm-bindgen-test = " 0.3"
Original file line number Diff line number Diff line change @@ -15,9 +15,17 @@ pub fn get_rng_impl(seed: Option<u64>) -> RngImpl {
15
15
RngImpl :: seed_from_u64( rand:: thread_rng( ) . next_u64( ) )
16
16
} else {
17
17
// no std_random feature build, use getrandom
18
- let mut buf = [ 0u8 ; 64 ] ;
19
- getrandom:: getrandom( & mut buf) . unwrap( ) ;
20
- RngImpl :: seed_from_u64( buf[ 0 ] as u64 )
18
+ #[ cfg( feature = "js" ) ]
19
+ {
20
+ let mut buf = [ 0u8 ; 64 ] ;
21
+ getrandom:: getrandom( & mut buf) . unwrap( ) ;
22
+ RngImpl :: seed_from_u64( buf[ 0 ] as u64 )
23
+ }
24
+ #[ cfg( not( feature = "js" ) ) ]
25
+ {
26
+ // Using 0 as default seed
27
+ RngImpl :: seed_from_u64( 0 )
28
+ }
21
29
}
22
30
}
23
31
}
You can’t perform that action at this time.
0 commit comments