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

Libz blitz/use question mark instead of unwrap in examples #141

Closed
wants to merge 4 commits into from

Conversation

Projects
None yet
2 participants
@muzikmoe
Copy link
Contributor

muzikmoe commented Oct 25, 2017

Should resolve #129

muzikmoe added some commits Oct 25, 2017

@KodrAus
Copy link

KodrAus left a comment

Thanks @muzikmoe! I think we should only show the body of your new fallible methods in the docs, I've left an example of how we can do this.

You can also always run cargo doc --no-deps --open locally to quickly view the new docs you're working on.

src/lib.rs Outdated
//!
//! let mut bugfix_release = Version::parse("1.0.0").unwrap();
//! bugfix_release.increment_patch();
//! fn try_increment_patch() -> Result<(), Box<Error>> {

This comment has been minimized.

@KodrAus

KodrAus Oct 25, 2017

I think we should hide the main function and signature of try_increment_patch so there's less noise in the examples. You can do this by adding a # at the start of a doc test line. Like:

//! # try_main() -> Result<(), Box<Error>> {
//! let mut bugfix_release = Version::parse("1.0.0")?;
//! ...
//! # Ok(())
//! # }
//! # fn main() { try_main().unwrap(); }

That way you only see the body of the try_main function, but the ? magically works.

src/lib.rs Outdated
//! use std::error::Error;
//!
//! fn try_compare() -> Result<(), Box<Error>> {
//!

This comment has been minimized.

@KodrAus

KodrAus Oct 25, 2017

This is a bit of a bit, but once we hide the method signatures in this example we'll need to remove this newline, otherwise the docs will have an empty line in them too.

@muzikmoe

This comment has been minimized.

Copy link
Contributor Author

muzikmoe commented Oct 26, 2017

rebased.
check out #144

@muzikmoe muzikmoe closed this Oct 26, 2017

@muzikmoe muzikmoe deleted the muzikmoe:libz_blitz/Use_question_mark_instead_of_unwrap_in_examples branch Oct 26, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.