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

Fix example dependency list #397

Merged
merged 1 commit into from
Feb 9, 2022
Merged

Conversation

tcharding
Copy link
Member

Example relies on rand-std not plain rand dependency.

I do not understand why the following command passes without this patch
applied

cargo test --no-default-features --features=std,rand,bitcoin_hashes

But if we put the same code in a standalone binary it fails as expected?

Since the running of this test is unusual and it is primarily meant as
an entry point example to the library, remove the mention of "alloc"
feature and just depend upon "std".

Fixes: #395

Example relies on `rand-std` not plain `rand` dependency.

I do not understand why the following command passes without this patch
applied

```
cargo test --no-default-features --features=std,rand,bitcoin_hashes
```

But if we put the same code in a standalone binary it fails as expected?

Since the running of this test is _unusual_ and it is primarily meant as
an entry point example to the library, remove the mention of "alloc"
feature and just depend upon "std".
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 3c9dd2f

If I understand the issue correctly, this example would not have have worked with alloc anyway, since it depends on std implicitly through rand-std.

Edit: forgot "not"

@apoelstra apoelstra merged commit b8615e2 into rust-bitcoin:master Feb 9, 2022
@tcharding
Copy link
Member Author

Its the "rand" vs "rand-std" thing that this PR really fixes.

I may have confused things by removing "alloc" at the same time, my bad. I dropped the "alloc" because I'm wondering if all the recent feature gates I changed were incorrect, it seems confusing to not have "std" enabled but have "rand-std" enabled, even if technically this all works. Why would anyone ever do this. But changing them all again seems like code churn, not sure what to do?

@apoelstra
Copy link
Member

@tcharding lol, I think the code churn would be ok. We haven't actually done a release yet.

My bad as well, for reading your changes and not noticing that rand-std and alloc is a nearly-incoherent combination ... although as you say, it does technically work.

For readers: we are talking about the recent changes in #386 commit 6, which replaces a bunch of rand feature gates with rand-std, but then doesn't change the simultaneous any(alloc, std) feature gate to std. This only affects documentation example code.

@tcharding tcharding deleted the fix-rand-dep branch February 11, 2022 08:36
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.

Is documentation outdated?
2 participants