Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init. reproduces rust-random/rand#1016
- Loading branch information
0 parents
commit e464734
Showing
5 changed files
with
234 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "rand1016" | ||
version = "0.1.0" | ||
authors = ["Kaz Wesley <kaz@lambdaverse.org>"] | ||
edition = "2018" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
wasm-bindgen = "0.2" | ||
rand = "0.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<html> | ||
<head> | ||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/> | ||
</head> | ||
<body> | ||
<!-- Note the usage of `type=module` here as this is an ES6 module --> | ||
<script type="module"> | ||
import init, { test_rand1016 } from './pkg/rand1016.js'; | ||
async function run() { | ||
await init(); | ||
const result = test_rand1016(); | ||
console.log(`result = ${result}`); | ||
} | ||
run(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use rand::Rng; | ||
|
||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen(start)] | ||
pub fn main() -> Result<(), JsValue> { Ok(()) } | ||
|
||
#[wasm_bindgen] | ||
pub fn test_rand1016() -> u32 { | ||
rand::thread_rng().gen() | ||
} |