Skip to content

Commit 719eeb2

Browse files
authored
Rollup merge of rust-lang#61990 - llogiq:questionmark-test, r=QuietMisdreavus
First question mark in doctest We have had `?` for `Result`s in doctests for some time, but so far haven't used them in doctests. With this PR, I want to start the de-`unwrap`ping of doctests – and the discussion on where to do so. There is one downside, which is that the code can no longer be copied into a plain `main()` method, on the other hand, there should be a workable error if one does this.
2 parents b0bd5f2 + ee05fc8 commit 719eeb2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/libcore/macros.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,14 @@ macro_rules! r#try {
335335
/// ```
336336
/// use std::io::Write;
337337
///
338-
/// let mut w = Vec::new();
339-
/// write!(&mut w, "test").unwrap();
340-
/// write!(&mut w, "formatted {}", "arguments").unwrap();
338+
/// fn main() -> std::io::Result<()> {
339+
/// let mut w = Vec::new();
340+
/// write!(&mut w, "test")?;
341+
/// write!(&mut w, "formatted {}", "arguments")?;
341342
///
342-
/// assert_eq!(w, b"testformatted arguments");
343+
/// assert_eq!(w, b"testformatted arguments");
344+
/// Ok(())
345+
/// }
343346
/// ```
344347
///
345348
/// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects

0 commit comments

Comments
 (0)