Skip to content

doc: make the conditional-compilation example work #34610

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

Merged
merged 3 commits into from
Jul 8, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/doc/book/conditional-compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ they get set in the [`[features]` section][features] of your `Cargo.toml`:
# no features by default
default = []

# Add feature "foo" here, then you can use it.
# Our "foo" feature depends on nothings else.
Copy link
Member

Choose a reason for hiding this comment

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

Can you change this to "nothing" rather than "nothings" please?

Copy link
Contributor Author

@wuranbo wuranbo Jul 6, 2016

Choose a reason for hiding this comment

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

OK~My english is poor.

Copy link
Member

Choose a reason for hiding this comment

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

No worries! 😄 I'm a native speaker and mine is often terrible.

foo = []

# The “secure-password” feature depends on the bcrypt package.
secure-password = ["bcrypt"]
# secure-password = ["bcrypt"]
Copy link
Member

Choose a reason for hiding this comment

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

Why is this one being commented out?

Copy link
Contributor Author

@wuranbo wuranbo Jul 6, 2016

Choose a reason for hiding this comment

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

When I run with this line: secure-password = ["bcrypt"]
I got an error
"
error: failed to parse manifest at /Users/wrb/github/wuranbo/gist/rust/workspace/hello_world/Cargo.toml

Caused by:
Feature secure-password includes bcrypt which is neither a dependency nor another feature
"
I did not know how to fix it, so comment. I read the book first time, just a newbie~~
And when I read this line, I got nothing about 'secure-password' in the whole chapter context.Really confused me.

So, tell me, how should I fix it?

Copy link
Member

Choose a reason for hiding this comment

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

Ah so, as the comment says

depends on the bcrypt package

If you don't have the package as a dependency, then it's going to give an error. Can we just remove these three lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh. thank you. I will remove these.

```

When you do this, Cargo passes along a flag to `rustc`:
Expand Down