Skip to content

Commit

Permalink
Merge pull request #2430 from jahwi/master
Browse files Browse the repository at this point in the history
Correct no-listing-10-result-in-tests: Take tests module out of the main function
  • Loading branch information
steveklabnik authored Aug 21, 2020
2 parents c0a6a61 + 53eaa8c commit 3c0ff23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#![allow(unused_variables)]
fn main() {}

// ANCHOR: here
#[cfg(test)]
mod tests {
#[test]
Expand All @@ -9,3 +13,4 @@ mod tests {
}
}
}
// ANCHOR_END: here
2 changes: 1 addition & 1 deletion src/ch11-01-writing-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ that use `Result<T, E>`! Here’s the test from Listing 11-1, rewritten to use
`Result<T, E>` and return an `Err` instead of panicking:

```rust
{{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/src/lib.rs}}
{{#rustdoc_include ../listings/ch11-writing-automated-tests/no-listing-10-result-in-tests/src/lib.rs:here}}
```

The `it_works` function now has a return type, `Result<(), String>`. In the
Expand Down

0 comments on commit 3c0ff23

Please sign in to comment.