Skip to content

Commit 9eaae9e

Browse files
morenolMec-iS
andauthored
Fixes for release (#237)
* Fixes for release * add new test * Remove change applied in development branch * Only add dependency for wasm32 * Update ci.yml Co-authored-by: Luis Moreno <morenol@users.noreply.github.com> Co-authored-by: Lorenzo <tunedconsulting@gmail.com>
1 parent 46b6285 commit 9eaae9e

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,16 @@ jobs:
4646
- name: Install test runner for wasi
4747
if: matrix.platform.target == 'wasm32-wasi'
4848
run: curl https://wasmtime.dev/install.sh -sSf | bash
49-
- name: Stable Build
49+
- name: Stable Build with all features
5050
uses: actions-rs/cargo@v1
5151
with:
5252
command: build
5353
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 }}
5459
- name: Tests
5560
if: matrix.platform.target == 'x86_64-unknown-linux-gnu' || matrix.platform.target == 'x86_64-pc-windows-msvc' || matrix.platform.target == 'aarch64-apple-darwin'
5661
uses: actions-rs/cargo@v1

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ ndarray = { version = "0.15", optional = true }
2626
num-traits = "0.2.12"
2727
num = "0.4"
2828
rand = { version = "0.8.5", default-features = false, features = ["small_rng"] }
29-
getrandom = "*"
3029
rand_distr = { version = "0.4", optional = true }
3130
serde = { version = "1", features = ["derive"], optional = true }
3231

@@ -40,7 +39,7 @@ std_rand = ["rand/std_rng", "rand/std"]
4039
js = ["getrandom/js"]
4140

4241
[target.'cfg(target_arch = "wasm32")'.dependencies]
43-
getrandom = { version = "*", features = ["js"] }
42+
getrandom = { version = "*", optional = true }
4443

4544
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dev-dependencies]
4645
wasm-bindgen-test = "0.3"

src/rand_custom.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,17 @@ pub fn get_rng_impl(seed: Option<u64>) -> RngImpl {
1515
RngImpl::seed_from_u64(rand::thread_rng().next_u64())
1616
} else {
1717
// 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+
}
2129
}
2230
}
2331
}

0 commit comments

Comments
 (0)