Skip to content
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

Merged
merged 8 commits into from
Aug 8, 2019
Merged

Add dummy feature #71

merged 8 commits into from
Aug 8, 2019

Conversation

newpavlov
Copy link
Member

@newpavlov newpavlov commented Aug 2, 2019

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.

@newpavlov newpavlov requested a review from dhardy August 2, 2019 14:05
Copy link
Member

@josephlr josephlr left a 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.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@newpavlov
Copy link
Member Author

newpavlov commented Aug 4, 2019

@josephlr
Thank you for the nits! Feel free to propose any other similar improvements!

Copy link
Member

@josephlr josephlr left a 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 Show resolved Hide resolved
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"`,
Copy link
Member

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).

Copy link
Member Author

@newpavlov newpavlov Aug 5, 2019

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.

@newpavlov newpavlov changed the title Add dummy and wasm_dummy features Add dummy feature Aug 5, 2019
Copy link
Member

@dhardy dhardy left a 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.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop using dummy implementation
3 participants