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

Explain meaning of Result iters and link to factory functions #38158

Merged
merged 1 commit into from
Dec 21, 2016

Conversation

sourcefrog
Copy link
Contributor

No description provided.

@rust-highfive
Copy link
Collaborator

r? @aturon

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

@bluss
Copy link
Member

bluss commented Dec 4, 2016

@bors r+ rollup

Thank you!

@bors
Copy link
Contributor

bors commented Dec 4, 2016

📌 Commit b2849c7 has been approved by bluss

Copy link
Member

@GuillaumeGomez GuillaumeGomez left a comment

Choose a reason for hiding this comment

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

A few things to fix.

@@ -501,6 +501,8 @@ impl<T, E> Result<T, E> {

/// Returns an iterator over the possibly contained value.
///
/// The iterator yields one value if the result is `Ok`, otherwise none.
Copy link
Member

Choose a reason for hiding this comment

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

Missing Ok's url.

@@ -520,6 +522,8 @@ impl<T, E> Result<T, E> {

/// Returns a mutable iterator over the possibly contained value.
///
/// The iterator yields one value if the result is `Ok`, otherwise none.
Copy link
Member

Choose a reason for hiding this comment

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

Missing Ok's url.

@@ -848,6 +852,8 @@ impl<T, E> IntoIterator for Result<T, E> {

/// Returns a consuming iterator over the possibly contained value.
///
/// The iterator yields one value if the result is `Ok`, otherwise none.
Copy link
Member

Choose a reason for hiding this comment

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

Missing Ok's url.

@@ -893,8 +899,13 @@ impl<'a, T, E> IntoIterator for &'a mut Result<T, E> {

/// An iterator over a reference to the [`Ok`] variant of a [`Result`].
///
/// The iterator yields one value if the result is `Ok`, otherwise none.
Copy link
Member

Choose a reason for hiding this comment

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

Missing Ok's url.

/// the [`IntoIterator`] trait).
/// An iterator over the value in a [`Ok`] variant of a [`Result`].
///
/// The iterator yields one value if the result is `Ok`, otherwise none.
Copy link
Member

Choose a reason for hiding this comment

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

Missing Ok's url.

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'll add them - it wasn't clear to me if the intention is to link every reference...

@GuillaumeGomez
Copy link
Member

@bors: r-

bors added a commit that referenced this pull request Dec 7, 2016
Rollup of 9 pull requests

- Successful merges: #38085, #38123, #38151, #38153, #38158, #38163, #38186, #38189, #38208
- Failed merges:
@sourcefrog
Copy link
Contributor Author

links added, please take another look

@sourcefrog
Copy link
Contributor Author

I'm not sure why https://travis-ci.org/rust-lang/rust/jobs/183046022 failed, maybe just a glitch?

@GuillaumeGomez
Copy link
Member

Don't worry, travis build is broken for the moment, so if no error/failed test, it's good. Can you squash your commits please? If you don't know how to do it, take a look here. Once done, ping me and I merge.

@sourcefrog
Copy link
Contributor Author

Don't worry, travis build is broken for the moment, so if no error/failed test, it's good. Can you squash your commits please? If you don't know how to do it, take a look here. Once done, ping me and I merge.

Will do.

Should we teach Bors to squash-and-merge?

@sourcefrog
Copy link
Contributor Author

sourcefrog commented Dec 13, 2016

Squashed, and rebased to current master.

@@ -848,6 +856,8 @@ impl<T, E> IntoIterator for Result<T, E> {

/// Returns a consuming iterator over the possibly contained value.
///
/// The iterator yields one value if the result is [`Ok`], otherwise none.
Copy link
Member

Choose a reason for hiding this comment

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

Otherwise None (with url).

@@ -501,6 +501,8 @@ impl<T, E> Result<T, E> {

/// Returns an iterator over the possibly contained value.
///
/// The iterator yields one value if the result is [`Ok`], otherwise none.
Copy link
Member

Choose a reason for hiding this comment

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

Otherwise None (with url).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, no, it doesn't yield None, it just yields no values at all.

I realize this is implemented by next() returning None but I think saying that would only make this confusing. I could rephrase it as "the iterator's next method returns Some of the inner and then None if the result is Ok, otherwise it returns None." But that seems to be needlessly puncturing the iterator abstraction.

A couple of general comments:

  • There are lots of references to well-known types such as None and Ok throughout the code without hyperlinks, indeed even in this very file. If the goal is that every type be manually linked maybe that should go into CONTRIBUTING.md to avoid make that clear. IMO it is not so necessary to linkify values the reader is highly likely to already understand, and that anyhow are linked from nearby.

  • In my experience repeatedly asking contributors for small incremental changes to a PR that's already an improvement tends to discourage future contributions. My normal practice now is to accept the change and encourage them to send another PR making additional cleanups, and I think this gives them a better feeling about contributing.

Copy link
Member

@GuillaumeGomez GuillaumeGomez Dec 14, 2016

Choose a reason for hiding this comment

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

No, it returns None, not "no values at all".

Also, I'm currently finishing to add missing doc examples, then I'll go through all missing urls. None and every other struct/enum/etc... should be linked.

Also, even it seems minor for you, it isn't for me since all these minor things people don't add, I have to after. And it's getting quite huge.

I don't ask it just to bother you or for extreme and dark reasons, it's really because there is a need out of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unless I'm misunderstanding it the iter will either have length 1 and contain the value inside the Ok result, or it will have length zero. It never yields None, unless the result is Ok(None). That's what I was trying to say by it yields 'no values at all'.

https://play.rust-lang.org/?gist=3d6a9500b782e878fae356a08888838b&version=stable&backtrace=0

Copy link
Member

@GuillaumeGomez GuillaumeGomez Dec 15, 2016

Choose a reason for hiding this comment

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

Ok, I see your point. Confusion on my side. Sorry about that... Therefore, no change is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem, I could have been confused myself so I appreciate you checking.

I can send you a little cleanup pr later to linkify other instances. It sure would be nice if we can make it automatic later.

Copy link
Member

Choose a reason for hiding this comment

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

It's been discussed for a while. You can take a look at this issue if you want to take a look at the current status.

@@ -520,6 +524,8 @@ impl<T, E> Result<T, E> {

/// Returns a mutable iterator over the possibly contained value.
///
/// The iterator yields one value if the result is [`Ok`], otherwise none.
Copy link
Member

Choose a reason for hiding this comment

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

Otherwise None (with url).

@@ -893,8 +905,13 @@ impl<'a, T, E> IntoIterator for &'a mut Result<T, E> {

/// An iterator over a reference to the [`Ok`] variant of a [`Result`].
///
/// The iterator yields one value if the result is [`Ok`], otherwise none.
Copy link
Member

Choose a reason for hiding this comment

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

Otherwise None (with url).

/// the [`IntoIterator`] trait).
/// An iterator over the value in a [`Ok`] variant of a [`Result`].
///
/// The iterator yields one value if the result is [`Ok`], otherwise none.
Copy link
Member

Choose a reason for hiding this comment

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

Otherwise None (with url).

@GuillaumeGomez
Copy link
Member

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Dec 15, 2016

📌 Commit 16d4b7b has been approved by GuillaumeGomez

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 15, 2016
Explain meaning of Result iters and link to factory functions
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 16, 2016
Explain meaning of Result iters and link to factory functions
@bors
Copy link
Contributor

bors commented Dec 16, 2016

⌛ Testing commit 16d4b7b with merge 02bb808...

@bors
Copy link
Contributor

bors commented Dec 16, 2016

💔 Test failed - auto-win-msvc-64-opt

@GuillaumeGomez
Copy link
Member

@bors: retry

@bors
Copy link
Contributor

bors commented Dec 16, 2016

⌛ Testing commit 16d4b7b with merge f5fa85e...

@bors
Copy link
Contributor

bors commented Dec 16, 2016

💔 Test failed - auto-mac-64-opt-rustbuild

@alexcrichton
Copy link
Member

alexcrichton commented Dec 16, 2016 via email

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 18, 2016
Explain meaning of Result iters and link to factory functions
@sanxiyn
Copy link
Member

sanxiyn commented Dec 19, 2016

@bors retry

@alexcrichton
Copy link
Member

@bors: retry

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Dec 20, 2016
Explain meaning of Result iters and link to factory functions
bors added a commit that referenced this pull request Dec 20, 2016
@bors bors merged commit 16d4b7b into rust-lang:master Dec 21, 2016
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.

8 participants