-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Improve AddrParseError
documentation.
#48853
Improve AddrParseError
documentation.
#48853
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joshtriplett (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
I like the premise of this change, adding information about what can cause an error. However, there's a certain tone this documentation takes that I'd rather we avoid. In particular, "rustc isn't angry anymore" seems problematic. Also, "because of wrong resource typing" doesn't quite make sense. "because the provided string does not parse as the given type, often because it includes information only handled by a different address type", perhaps? |
Yes, I'll replace that with a more neutral sentence. edit:
I'm fine with that too. That's more exhaustive. |
The changes were applied. Thanks! |
src/libstd/net/parser.rs
Outdated
/// | ||
/// ``` | ||
/// use std::net::SocketAddr; | ||
/// // That's it. `rustc` isn't angry anymore. | ||
/// // No problem, `panic!` message has disappear. |
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.
Nit: "has disappeared" rather than "has disappear". Also, need a "the" before the panic!
.
Looks good otherwise, thanks for the update!
src/libstd/net/parser.rs
Outdated
/// # Potential causes: | ||
/// | ||
/// `AddrParseError` may be thrown because the provided string does not parse as the given type, | ||
/// often because it includes informations only handled by a different address type. |
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.
"information" is invariable. "pieces of information"
src/libstd/net/parser.rs
Outdated
/// | ||
/// ``` | ||
/// use std::net::SocketAddr; | ||
/// // No problem, the `panic!` message has disappeared. |
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.
Please add an empty line.
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.
Done. I hope that's what you wanted. I didn't know if it was for line 389 or 390.
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.
No, it's the correct place. :)
If that's ok for you, that should be ok for me too. :) |
It's time to squash. |
a1f0565
to
0931715
Compare
Done! |
src/libstd/net/parser.rs
Outdated
@@ -372,6 +372,25 @@ impl FromStr for SocketAddr { | |||
/// [`IpAddr`], [`Ipv4Addr`], [`Ipv6Addr`], [`SocketAddr`], [`SocketAddrV4`], and | |||
/// [`SocketAddrV6`]. | |||
/// | |||
/// # Potential causes: | |||
/// | |||
/// `AddrParseError` may be thrown because the provided string does not parse as the given type, |
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.
Sorry, forgot to ask you to turn this into an url (like done in a few places here too).
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.
The current page we are reading is the AddrParseError
page. It seemed useless to me, but, ok, I'll apply the changes.
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.
Ah then my bad. Just ignore this comment.
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.
Too fast, I had applied the changes. :)
src/libstd/net/parser.rs
Outdated
@@ -372,6 +372,25 @@ impl FromStr for SocketAddr { | |||
/// [`IpAddr`], [`Ipv4Addr`], [`Ipv6Addr`], [`SocketAddr`], [`SocketAddrV4`], and | |||
/// [`SocketAddrV6`]. | |||
/// | |||
/// # Potential causes: |
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.
Please remove ":".
src/libstd/net/parser.rs
Outdated
/// | ||
/// ```should_panic | ||
/// use std::net::IpAddr; | ||
/// let _foo: IpAddr = "127.0.0.1:8080".parse().unwrap(); // panic! |
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.
We should never use unwrap
in examples (or in code more generally). At worst, please use expect
.
src/libstd/net/parser.rs
Outdated
/// use std::net::SocketAddr; | ||
/// | ||
/// // No problem, the `panic!` message has disappeared. | ||
/// let _foo: SocketAddr = "127.0.0.1:8080".parse().unwrap(); |
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.
Same.
src/libstd/net/parser.rs
Outdated
/// ``` | ||
/// | ||
/// [`FromStr`]: ../../std/str/trait.FromStr.html | ||
/// [`AddrParseError`]: ../../std/net/struct.AddrParseError.html |
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.
Just like you said, it's useless to do this since we're already on the correct page (sorry again about this...).
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.
Hi,
Yes, it was removed. See 11be095203a084733966e9d52b1c0489bbd22056.
Add a potential cause to `AddrParseError` raising.
11be095
to
5e991e1
Compare
Thanks! @bors: r+ rollup |
📌 Commit 5e991e1 has been approved by |
…ion_improvement, r=GuillaumeGomez Improve `AddrParseError` documentation. I've added potential cause to `AddrParseError` raising.
I've added potential cause to
AddrParseError
raising.