Skip to content

Use match expression directly in guide.md #18120

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 1 commit into from
Oct 19, 2014
Merged

Conversation

jrincayc
Copy link
Contributor

Use a match expression directly in the println statement, instead of creating a second variable. It seems weird that the current guide.md complains about creating an extra variable, when the same feature could be demonstrated without creating the extra variable.

Use a match expression directly in the println statement, instead of creating a second variable.
@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pcwalton (or someone else) soon.

@steveklabnik
Copy link
Member

The point is to clearly show that the result of match is an expression, to be used however you see fit. I actually think that this is less clear.

@steveklabnik
Copy link
Member

@aturon do we have any style guidelines here?

@huonw
Copy link
Member

huonw commented Oct 17, 2014

I agree that inlining the multiline match directly into the oneline println! is less clear, but it does seem like the complaint is strange: the temporary is "needed" for code clarity.

@jrincayc
Copy link
Contributor Author

I agree that stylistically, putting the match directly inside the println! is somewhat ugly. I don't like how the documentation currently complains about doing an extra variable however, since the extra variable is unnecessary. (and for what it is worth, on O2, it looks like the compiler realizes that result is a constant and optimizes it away.)

bors added a commit that referenced this pull request Oct 19, 2014
Use a match expression directly in the println statement, instead of creating a second variable.  It seems weird that the current guide.md complains about creating an extra variable, when the same feature could be demonstrated without creating the extra variable.
@bors bors closed this Oct 19, 2014
@bors bors merged commit ce83a24 into rust-lang:master Oct 19, 2014
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.

7 participants