Skip to content

Add dummy feature - #71

Merged
newpavlov merged 8 commits into
masterfrom
dummy_feature
Aug 8, 2019
Merged

Add dummy feature#71
newpavlov merged 8 commits into
masterfrom
dummy_feature

Conversation

@newpavlov

@newpavlovnewpavlov commented Aug 2, 2019

Copy link
Copy Markdown
Member

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 dhardyAugust 2, 2019 14:05

@josephlrjosephlr left a comment

Copy link
Copy Markdown
Member

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.

Comment threadREADME.md Outdated
Comment threadREADME.md Outdated
Comment threadCargo.toml Outdated
Comment threadREADME.md Outdated
Comment threadsrc/lib.rs Outdated
@newpavlov

newpavlov commented Aug 4, 2019

Copy link
Copy Markdown
MemberAuthor

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

@josephlrjosephlr left a comment

Copy link
Copy Markdown
Member

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.

Comment threadsrc/lib.rs Outdated
Comment threadsrc/lib.rs Outdated
)))] {
#[path = "rdrand.rs"] mod imp;
} else if #[cfg(target_arch = "wasm32")] {
// ideally we would like to use `target = "wasm32-unknown-unknown"`,

Copy link
Copy Markdown
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:

...}elseif#[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).

@newpavlovnewpavlovAug 5, 2019

Copy link
Copy Markdown
MemberAuthor

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.

@newpavlovnewpavlov changed the title Add dummy and wasm_dummy featuresAdd dummy featureAug 5, 2019

@dhardydhardy left a comment

Copy link
Copy Markdown
Member

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.

Comment threadREADME.md Outdated
Comment threadREADME.md Outdated
Comment threadsrc/lib.rs Outdated
Comment threadsrc/lib.rs Outdated
@newpavlov
newpavlov merged commit 7449a08 into masterAug 8, 2019
@newpavlov
newpavlov deleted the dummy_feature branch August 8, 2019 14:31
@dhardydhardy mentioned this pull request Sep 20, 2019
@josephlrjosephlr mentioned this pull request Sep 20, 2019
takumi-earth pushed a commit to earthlings-dev/getrandom that referenced this pull request Jan 27, 2026
Sign up for freeto 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

@newpavlov@dhardy@josephlr