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

Avoid PartialEq in book explanation of enums #21207

Closed
wants to merge 1 commit into from

Conversation

mdinger
Copy link
Contributor

@mdinger mdinger commented Jan 15, 2015

This was a quick rewrite to try and address #21196. I doubt the tone is as light as when @steveklabnik usually writes so it may be a little out of place. I prefer it a little drier but opinions vary.

I figure better to use match and ask the reader for patience as it's covered in more detail in the next section than to take a complicated route through PartialEq and such to avoid match.

I also tried to elaborate a little on Other because I thought the first seeing of a type without data is pretty weird. I'm hoping for comments to see if others think it's better as well.

@rust-highfive
Copy link
Collaborator

r? @huonw

(rust_highfive has picked a reviewer for you, use r? to override)

@mdinger
Copy link
Contributor Author

mdinger commented Jan 15, 2015

r? @steveklabnik

else if a > b { Ordering::Greater }
else { Ordering::Equal }
}
```{rust, norun}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't remember how you tell rustdoc not to test this example (if this is wrong)...I'll look it up later

Copy link
Contributor

Choose a reason for hiding this comment

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

It's {rust,ignore}. See intro for examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed


You can also have any number of values in an enum:
let nine = Character::Digit(9i32);
let not_a_digit = Other;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Self note: should be Character::Other

@steveklabnik
Copy link
Member

Hey, sorry for taking a while to review this. :(

The reason I cover Ordering here is becuase we actually use it later in the guessing game, so I don't think changing it this much is appropriate. Thank you!

@mdinger
Copy link
Contributor Author

mdinger commented Jan 22, 2015

@steveklabnik How come when @alexcrichton closes things we can reopen but when you close things we can't? Is that an admin option? It also blocks modifying the branch so we can ask for review again. We'd have to make a new PR.

I didn't know Ordering was required. I think this provides more info regarding enums than the original does aside from bypassing Ordering and is much more compact. I think it's in a better position for introducing PartialEq/Ordering because there's more details but I don't know if you approve of the format.

@steveklabnik
Copy link
Member

@mdinger I have no idea what you're talking about. @alexcrichton and I have the same permissions, and, I'd imagine, clicked the same close button. I closed becuase I'd imagine that totally re-doing it would end up being a new PR.

@mdinger
Copy link
Contributor Author

mdinger commented Jan 22, 2015

@steveklabnik Things like here: #20601 (comment)

Maybe I just made a mistake and assumed that meant we could reopen. I thought I'd seen it reopened but can't find one.

@mdinger mdinger deleted the enum_rewording branch March 12, 2015 04:27
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.

5 participants