-
Notifications
You must be signed in to change notification settings - Fork 13.4k
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
Conversation
@alexcrichton can I add doctests for |
Feel free to add it here, feel free to ping me when this is updated, thanks @jbranchaud! |
@alexcrichton I've added doctests for |
Thanks @jbranchaud! |
@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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
29578c5
to
451cc7e
Compare
I've addressed @gankro's comments and squashed the commits. /cc @alexcrichton |
…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.
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.