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

Update docs on Error struct. #29355 #42837

Merged
merged 1 commit into from
Jul 19, 2017
Merged

Conversation

rthomas
Copy link
Contributor

@rthomas rthomas commented Jun 22, 2017

This adds a pretty contrived example of the usage of fmt::Error. I am
very open to suggestions for a better one.

I have also highlighted the fmt::Error vs std::error::Error.

r? @steveklabnik

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (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.

@shepmaster shepmaster added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 23, 2017
Copy link
Member

@steveklabnik steveklabnik left a comment

Choose a reason for hiding this comment

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

some nits. I agree that the example is not spectacular, but I have no better suggestions right now, and so it's fine.

@@ -81,6 +81,21 @@ pub type Result = result::Result<(), Error>;
/// This type does not support transmission of an error other than that an error
/// occurred. Any extra information must be arranged to be transmitted through
/// some other means.
///
/// The key thing to remember here is that the type `fmt::Error` should not be
Copy link
Member

Choose a reason for hiding this comment

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

I would say "An important thing to remember is" instead, that is, this is very important, but not the thing, IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/// # Example
///
/// ```rust
/// use std::fmt;
Copy link
Member

Choose a reason for hiding this comment

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

use std::fmt{self, write};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/// use std::fmt;
///
/// let mut output = String::new();
/// match fmt::write(&mut output, format_args!("Hello {}!", "world")) {
Copy link
Member

Choose a reason for hiding this comment

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

match write

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/// match fmt::write(&mut output, format_args!("Hello {}!", "world")) {
/// Err(fmt::Error) => panic!("An error occurred"),
/// _ => (),
/// }
Copy link
Member

Choose a reason for hiding this comment

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

instead of match, using unwrap_or_else is more idiomatic here

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 agree it would be more idiomatic, but that would not demonstrate the usage of fmt::Error - so I'm not sure if it would be worth including the example in that case.

@@ -81,6 +81,21 @@ pub type Result = result::Result<(), Error>;
/// This type does not support transmission of an error other than that an error
/// occurred. Any extra information must be arranged to be transmitted through
/// some other means.
///
/// The key thing to remember here is that the type `fmt::Error` should not be
/// confused with `std::error::Error`, which you may also have in scope.
Copy link
Member

Choose a reason for hiding this comment

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

If we're comparing to other Errors within the standard library, it might also be good to include std::io::Error, which I would consider more well-known than the Error trait.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 2, 2017
@rthomas
Copy link
Contributor Author

rthomas commented Jul 3, 2017

I've pushed up a commit with the review comments addressed in it.

The only potentially open issue is the example.

@rthomas
Copy link
Contributor Author

rthomas commented Jul 5, 2017

Friendly ping.

@steveklabnik
Copy link
Member

Sorry about this! I took Monday of work to get a four-day weekend 😄

I will review this later today.

Copy link
Member

@steveklabnik steveklabnik left a comment

Choose a reason for hiding this comment

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

Hi! Sorry again. Two extremely tiny nits, and then let's :shipit: . Ping me once they're changed and I will merge post-haste!

@@ -1,3 +1,4 @@

Copy link
Member

Choose a reason for hiding this comment

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

can you remove this please?

/// confused with `std::io::Error` or `std::error::Error`, which you may also
/// have in scope.
///
/// # Example
Copy link
Member

Choose a reason for hiding this comment

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

This should be Examples even though there's only one, for consistency.

@rthomas
Copy link
Contributor Author

rthomas commented Jul 5, 2017

Thanks @steveklabnik I've fixed up the issues and pushed the commit up - would you like me to squash them down or are they fine as is?

@rthomas
Copy link
Contributor Author

rthomas commented Jul 11, 2017

@steveklabnik friendly ping.

@arielb1 arielb1 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 11, 2017
@steveklabnik
Copy link
Member

@rthomas sorry, somehow I missed this!

Yeah, if you could squash, that'd be great. Happy to merge after 😄

This adds a pretty contrived example of the usage of fmt::Error. I am
very open to suggestions for a better one.

I have also highlighted the fmt::Error vs std::error::Error.

r? @steveklabnik
@rthomas
Copy link
Contributor Author

rthomas commented Jul 13, 2017

Thanks @steveklabnik, I have squashed the commits.

@carols10cents
Copy link
Member

@steveklabnik looks like this is ready for your r!

@steveklabnik
Copy link
Member

@bors: r+ rollup

thanks so much, and sorry again about the delays

@bors
Copy link
Contributor

bors commented Jul 17, 2017

📌 Commit aca6cd0 has been approved by steveklabnik

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jul 18, 2017
Update docs on Error struct. rust-lang#29355

This adds a pretty contrived example of the usage of fmt::Error. I am
very open to suggestions for a better one.

I have also highlighted the fmt::Error vs std::error::Error.

r? @steveklabnik
bors added a commit that referenced this pull request Jul 18, 2017
Rollup of 11 pull requests

- Successful merges: #42837, #43282, #43287, #43290, #43292, #43294, #43304, #43310, #43312, #43314, #43315
- Failed merges:
@bors bors merged commit aca6cd0 into rust-lang:master Jul 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants