-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Modify doctest's auto-fn main()
to allow Result
s
#56470
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,24 @@ | ||||||||||
// compile-flags:--test | ||||||||||
|
||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
will be needed to actually run the examples as doctests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool! Thank you! |
||||||||||
/// A check of using various process termination strategies | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To actually run any of the doctests in this file it needs to contain There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops. |
||||||||||
/// | ||||||||||
/// # Examples | ||||||||||
/// | ||||||||||
/// ```rust | ||||||||||
/// assert!(true); // this returns `()`, all is well | ||||||||||
/// ``` | ||||||||||
/// | ||||||||||
/// You can also simply return `Ok(())`, but you'll need to disambiguate the | ||||||||||
/// type using turbofish, because we cannot infer the type: | ||||||||||
/// | ||||||||||
/// ```rust | ||||||||||
/// Ok::<(), &'static str>(()) | ||||||||||
/// ``` | ||||||||||
/// | ||||||||||
/// You can err with anything that implements `Debug`: | ||||||||||
/// | ||||||||||
/// ```rust,should_panic | ||||||||||
/// Err("This is returned from `main`, leading to panic")?; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find this use of I think that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, but how should I test this particular function then? I could replace the |
||||||||||
/// Ok::<(), &'static str>(()) | ||||||||||
/// ``` | ||||||||||
pub fn check_process_termination() {} |
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.
Typo:
io:Error
should beio::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.
Good catch. WIll fix in a follow-up.