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
Libz blitz/use question mark instead of unwrap in examples #141
Conversation
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.
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>> { |
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.
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>> { | ||
//! |
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.
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.
rebased. |
Should resolve #129