-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dummy feature #71
Conversation
54bb8d7
to
c7ab9c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Mostly just grammar/phrasing nits.
@josephlr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup! Just a few nits. They're essentially just personal preference, so feel free to ignore.
src/lib.rs
Outdated
@@ -225,18 +227,30 @@ cfg_if! { | |||
target_env = "sgx", | |||
)))] { | |||
#[path = "rdrand.rs"] mod imp; | |||
} else if #[cfg(target_arch = "wasm32")] { | |||
// ideally we would like to use `target = "wasm32-unknown-unknown"`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I find something like:
...
} else if #[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))] {
#[path = "wasm32_bindgen.rs"] mod imp;
} else if #[cfg(all(target_arch = "wasm32", feature = "stdweb"))] {
#[path = "wasm32_stdweb.rs"] mod imp;
} else if #[cfg(feature = "dummy")] {
#[path = "dummy.rs"] mod imp;
} else {
compile_error!("\
...
to be a little more readable. It avoids nested cfg_if!
s, and we don't need the unknown
specifier. If we get here, the other wasm32
cases are taken care of.
In theory, a new wasm32
target could be added that's not addressed in the above, but having the stdweb
/wasm-bindgen
features work in that case seems fine (even ideal).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about not needing the unknown
specifier. Imagine that we don't have WASI or Emscripten and they will be added in future, with this config even if getrandom
will work on them, I wouldn't call it a correct target support. But I guess since we can't use target_vendor
here, we are not completely future proof anyway, so it makes sense to simplify the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this is a good way to solve the issue.
Closes #49
Strictly speaking it may be considered a breaking change. We could make
dummy
feature enabled-by-default, but I am not sure if we should.