From 842c5494f69d0958854751e03f2e53735545112d Mon Sep 17 00:00:00 2001 From: Mauri Mustonen Date: Sat, 20 Aug 2022 12:40:13 +0300 Subject: [PATCH 1/6] add description about Cargo js feature --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 5ecfad1c..4f3591fd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,6 +74,14 @@ //! and Node.js environments are supported, invoking the methods //! [described above](#supported-targets) using the [`wasm-bindgen`] toolchain. //! +//! To enable `js` Cargo feature. Place following line under dependencies +//! section in your `Cargo.toml` file. Even `getrandom` is not direct dependency +//! for you, you still need to add this line to enable the `js` feature. +//! ```toml +//! [dependencies] +//! getrandom = { version = "0.2", features = ["js"] } +//! ``` +//! //! This feature has no effect on targets other than `wasm32-unknown-unknown`. //! //! ### Custom implementations From 444cf1eabd6344f7c3b871a6cfec96fd739a82f0 Mon Sep 17 00:00:00 2001 From: Mauri Mustonen Date: Fri, 26 Aug 2022 15:14:48 +0300 Subject: [PATCH 2/6] add note about different crate types --- src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 4f3591fd..9050e0ac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,7 +82,9 @@ //! getrandom = { version = "0.2", features = ["js"] } //! ``` //! -//! This feature has no effect on targets other than `wasm32-unknown-unknown`. +//! Note this feature should only be enabled for binary crates. Not for library, +//! tests and benchmarks crates. This feature has no effect on targets other +//! than `wasm32-unknown-unknown`. //! //! ### Custom implementations //! From ad46bc359f43da027505db3811767df52c25aebb Mon Sep 17 00:00:00 2001 From: Mauri Mustonen Date: Fri, 26 Aug 2022 15:27:03 +0300 Subject: [PATCH 3/6] clean up --- src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9050e0ac..941366b4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,9 +82,11 @@ //! getrandom = { version = "0.2", features = ["js"] } //! ``` //! -//! Note this feature should only be enabled for binary crates. Not for library, -//! tests and benchmarks crates. This feature has no effect on targets other -//! than `wasm32-unknown-unknown`. +//! Note this feature should only be enabled for binary crates. For library, +//! tests and benchmarks crates, only enable this for tests and benchmarks, not +//! for the whole library. +//! +//! This feature has no effect on targets other than `wasm32-unknown-unknown`. //! //! ### Custom implementations //! From 8224f86aa9f5e3be1722dd1f7e60c313163c284e Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Sun, 28 Aug 2022 17:24:10 -0700 Subject: [PATCH 4/6] Fix wording/grammer Signed-off-by: Joe Richey --- src/lib.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 941366b4..3b4166e1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,17 +74,19 @@ //! and Node.js environments are supported, invoking the methods //! [described above](#supported-targets) using the [`wasm-bindgen`] toolchain. //! -//! To enable `js` Cargo feature. Place following line under dependencies -//! section in your `Cargo.toml` file. Even `getrandom` is not direct dependency -//! for you, you still need to add this line to enable the `js` feature. +//! To enable the `js` Cargo feature, add the following to the `dependencies` +//! section in your `Cargo.toml` file: //! ```toml //! [dependencies] //! getrandom = { version = "0.2", features = ["js"] } //! ``` //! -//! Note this feature should only be enabled for binary crates. For library, -//! tests and benchmarks crates, only enable this for tests and benchmarks, not -//! for the whole library. +//! This can be done even if `getrandom` is not a direct dependency. Cargo +//! allows crates to enable features for indirect dependencies. +//! +//! This feature should only be enabled for binary, test, or benchmark crates. +//! Library crates should generally not enable this feature, leaving such a +//! decision to *users* of their library. //! //! This feature has no effect on targets other than `wasm32-unknown-unknown`. //! From e0bb6034d3ef6b4db4f3ddc90c216bf843b6f493 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Sun, 28 Aug 2022 17:24:28 -0700 Subject: [PATCH 5/6] Remove "Indirect Depenencies" section This is now redundent, now that we've claried documentation in the WebAssembly support section Signed-off-by: Joe Richey --- src/lib.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3b4166e1..76938185 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -102,16 +102,6 @@ //! using `rdrand` and `js` Cargo features) continue using their normal //! implementations even if a function is registered. //! -//! ### Indirect Dependencies -//! -//! If `getrandom` is not a direct dependency of your crate, you can still -//! enable any of the above fallback behaviors by enabling the relevant -//! feature in your root crate's `Cargo.toml`: -//! ```toml -//! [dependencies] -//! getrandom = { version = "0.2", features = ["js"] } -//! ``` -//! //! ## Early boot //! //! Sometimes, early in the boot process, the OS has not collected enough From e05ec40b807e6f62547cf6ea9887feb285c4cebc Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Tue, 30 Aug 2022 00:54:13 -0700 Subject: [PATCH 6/6] Note that libraries shouldn't add their own JS feature Signed-off-by: Joe Richey --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 76938185..d7f67722 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -86,7 +86,8 @@ //! //! This feature should only be enabled for binary, test, or benchmark crates. //! Library crates should generally not enable this feature, leaving such a -//! decision to *users* of their library. +//! decision to *users* of their library. Also, libraries should not introduce +//! their own `js` features *just* to enable `getrandom`'s `js` feature. //! //! This feature has no effect on targets other than `wasm32-unknown-unknown`. //!