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

Various improvements in std::collections docs #41286

Merged
merged 4 commits into from
Apr 15, 2017
Merged

Various improvements in std::collections docs #41286

merged 4 commits into from
Apr 15, 2017

Conversation

chordowl
Copy link
Contributor

The meat of this PR are:

  • changes to (almost all?) iterator struct docs in std::collections such that they use the standard iterator boilerplate and state where they are created
  • a bunch of added links (at least as much as possible given std::collections mostly being a facade and whatnot 😅)
  • an example for Bound
  • changed phrasing for some summary sentences to be less redundant as well as more consistant with others in the module

There also are various other fixes, e.g. removing parens from method names in the module docs, changing some imperatives to 3rd person, etc.

r? @steveklabnik

lukaramu added 3 commits April 13, 2017 22:51
* Added links where possible (limited because of facading)
* Changed references to methods from `foo()` to `foo` in module docs
* Changed references to methods from `HashMap::foo` to just `foo` in
  top-level docs for `HashMap` and the `default` doc for `DefaultHasher`
* Various small other fixes
* Changed btree_map's and hash_map's Entry (etc.) docs to be consistent
* Changed VecDeque's type and module summary sentences to be consistent
  with each other as well as with other summary sentences in the module
* Changed HashMap's and HashSet's summary sentences to be less redundantly
  phrased and also more consistant with the other summary sentences in the
  module
* Also, added an example to Bound
@frewsxcv frewsxcv added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Apr 13, 2017
Copy link
Member

@frewsxcv frewsxcv left a comment

Choose a reason for hiding this comment

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

This is so great, thanks so much! Just a couple comments

@@ -218,10 +219,14 @@ pub struct BinaryHeap<T> {
data: Vec<T>,
}

/// A container object that represents the result of the [`peek_mut`] method
/// on `BinaryHeap`. See its documentation for details.
/// Object representing a mutable reference to the greatest item on a
Copy link
Member

Choose a reason for hiding this comment

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

I think we try to avoid using the term 'object' to describe structures since Rust isn't really OO. Personally I use 'structure', though there might be a better word.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe "Structure wrapping a mutable reference..."?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that sounds better!

/// map.insert(5, "b");
/// map.insert(8, "c");
///
/// for (key, value) in map.range((Excluded(3), Included(8))) {
Copy link
Member

Choose a reason for hiding this comment

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

I think you should be able to use the Range sugar here: 4..9

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's true. I adapted this example from the one for BTreeMap::range, which I agree is not ideal; as far as I could tell those kinds of methods are the only place in the (stable) standard library where Bound can be used right now though. I'd rather use something like the examples in RangeArgument, but that's not stable yet so I wasn't sure if that is ok to use.

@frewsxcv frewsxcv added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 14, 2017
@chordowl
Copy link
Contributor Author

Linkchecker is failing on the links I added to HashSet. I thought it should work since it does for HashMap, but upon investigation it seems like it's whitelisted here (see #32130).

Should I add it to the whitelist, or should I remove the links there again (and in other places too)? I feel like the docs are better with the links there in the version directly in std::collections, but at the same time, it's unfortunate that the version that's within std::collections::hash_set has broken links...

@frewsxcv
Copy link
Member

Should I add it to the whitelist, or should I remove the links there again (and in other places too)? I feel like the docs are better with the links there in the version directly in std::collections, but at the same time, it's unfortunate that the version that's within std::collections::hash_set has broken links...

Yeah, it's a bit of an unfortunate situation right now with docs links, though hopefully it will be fixed in the future. Either whitelisting or removing the links is fine with me. Do whichever your prefer!

@@ -135,6 +135,23 @@ mod std {
}

/// An endpoint of a range of keys.
/// # Examples
Copy link
Member

Choose a reason for hiding this comment

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

there should be an extra /// above this line

* Bound:
  * Added another example using RangeArgument to illustrate how Bound maps
    to range endpoints.
  * Added a note to the existing example that says that it's better to use
    range syntax in most cases
  * Added missing /// line
* binary_heap::PeakMut: s/Object representing/Structure wrapping
* added collections/hash_set/struct.HashSet.html to linkchecker whitelist
@chordowl
Copy link
Contributor Author

I went with adding collections/hash_set/struct.HashSet.html to the whitelist.

After talking about it on IRC, I also added a second example for Bound. It uses the unstable RangeArgument trait, but I think it's the more illustrative one; I placed it first accordingly. I also added a note the existing example, that should address the comment about being able to use range sugar.

@frewsxcv
Copy link
Member

Wooo thanks! ✨

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 15, 2017

📌 Commit 2a23e6e has been approved by frewsxcv

@bors
Copy link
Contributor

bors commented Apr 15, 2017

⌛ Testing commit 2a23e6e with merge 5f13a3b...

bors added a commit that referenced this pull request Apr 15, 2017
Various improvements in std::collections docs

The meat of this PR are:
* changes to (almost all?) iterator struct docs in std::collections such that they use the standard iterator boilerplate and state where they are created
* a bunch of added links (at least as much as possible given std::collections mostly being a facade and whatnot 😅)
* an example for `Bound`
* changed phrasing for some summary sentences to be less redundant as well as more consistant with others in the module

There also are various other fixes, e.g. removing parens from method names in the module docs, changing some imperatives to 3rd person, etc.

r? @steveklabnik
@bors
Copy link
Contributor

bors commented Apr 15, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: frewsxcv
Pushing 5f13a3b to master...

@bors bors merged commit 2a23e6e into rust-lang:master Apr 15, 2017
@chordowl chordowl deleted the std-collections-docs branch April 15, 2017 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants