Skip to content

Add a rustdoc test for union to exhibit how it is used. #19488

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
Dec 7, 2014

Conversation

jbranchaud
Copy link
Contributor

There is already a test for union in the test namespace, but this commit adds a doctest that will appear in the rustdocs.

Someone on IRC said, Write doctests!, so here I am.

I am not sure this is the best way to demonstrate the behavior of the union function, so I am open to suggestions for improving this. If I am on the right track I'd be glad to include similar doctests for intersection, difference, etc.

@jbranchaud
Copy link
Contributor Author

@alexcrichton can I add doctests for intersection, difference, and symmetric_difference on this PR or should I submit those as separate PRs?

@alexcrichton
Copy link
Member

Feel free to add it here, feel free to ping me when this is updated, thanks @jbranchaud!

@jbranchaud
Copy link
Contributor Author

@alexcrichton I've added doctests for intersection, difference, and symmetric_difference.

@alexcrichton
Copy link
Member

Thanks @jbranchaud!

@jbranchaud
Copy link
Contributor Author

@alexcrichton no problem! It is fun being able to learn Rust and contribute to it at the same time.

/// let mut diff = a.difference(&b);
///
/// assert_eq!(*diff.next().unwrap(), 1u);
/// assert_eq!(diff.next(), None);
Copy link
Contributor

Choose a reason for hiding this comment

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

Late to the party, but I wonder if these would be cleaner and/or more clear if they were .collect()ed into a Vec on-which we run the comparison?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gankro I can do that. I was actually just noticing that that is more or less what is done for corresponding methods of some of the other data structures.

Add a rustdoc test for union to exhibit how it is used.

There is already a test for union in the test namespace, but this commit
adds a doctest that will appear in the rustdocs.

Add a doctest for the difference function.

Add a doctest for the symmetric_difference function.

Add a doctest for the intersection function.

Update the union et al. doctests based on @gankro's comments.

Make the union et al. doctests a bit more readable.
@jbranchaud jbranchaud force-pushed the add-btree-set-doctests branch from 29578c5 to 451cc7e Compare December 5, 2014 23:00
@jbranchaud
Copy link
Contributor Author

I've addressed @gankro's comments and squashed the commits. /cc @alexcrichton

bors added a commit that referenced this pull request Dec 7, 2014
…crichton

There is already a test for `union` in the test namespace, but this commit adds a doctest that will appear in the rustdocs.

Someone on IRC said, *Write doctests!*, so here I am.

I am not sure this is the best way to demonstrate the behavior of the union function, so I am open to suggestions for improving this. If I am on the right track I'd be glad to include similar doctests for `intersection`, `difference`, etc.
@bors bors closed this Dec 7, 2014
@bors bors merged commit 451cc7e into rust-lang:master Dec 7, 2014
@jbranchaud jbranchaud deleted the add-btree-set-doctests branch December 10, 2014 03:41
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.

4 participants