Skip to content

Commit

Permalink
Correct no-listing-10-result-in-tests: Take tests module out of the m…
Browse files Browse the repository at this point in the history
…ain function
  • Loading branch information
jahwi committed Aug 15, 2020
1 parent c981c71 commit 53eaa8c
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 53eaa8c

Please sign in to comment.