Skip to content

Commit

Permalink
update original
Browse files Browse the repository at this point in the history
  • Loading branch information
funkill committed Apr 19, 2024
1 parent 4ce2b9f commit 289f3c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use adder;
use adder::add_two;

#[test]
fn it_adds_two() {
assert_eq!(4, adder::add_two(2));
assert_eq!(4, add_two(2));
}
5 changes: 3 additions & 2 deletions rustbook-en/src/ch11-03-test-organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ Enter the code in Listing 11-13 into the *tests/integration_test.rs* file:
`adder` crate</span>

Each file in the `tests` directory is a separate crate, so we need to bring our
library into each test crate’s scope. For that reason we add `use adder` at the
top of the code, which we didn’t need in the unit tests.
library into each test crate’s scope. For that reason we add `use
adder::add_two` at the top of the code, which we didn’t need in the unit
tests.

We don’t need to annotate any code in *tests/integration_test.rs* with
`#[cfg(test)]`. Cargo treats the `tests` directory specially and compiles files
Expand Down
8 changes: 4 additions & 4 deletions rustbook-en/src/ch18-02-refutability.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ the code in the curly brackets, giving it a way to continue validly. Listing
<span class="caption">Listing 18-9: Using `if let` and a block with refutable
patterns instead of `let`</span>

We’ve given the code an out! This code is perfectly valid, although it means we
cannot use an irrefutable pattern without receiving a warning. If we give `if
let` a pattern that will always match, such as `x`, as shown in Listing 18-10,
the compiler will give a warning.
We’ve given the code an out! This code is perfectly valid now. However,
if we give `if let` an irrefutable pattern (a pattern that will always
match), such as `x`, as shown in Listing 18-10, the compiler will give a
warning.

```rust
{{#rustdoc_include ../listings/ch18-patterns-and-matching/listing-18-10/src/main.rs:here}}
Expand Down

0 comments on commit 289f3c0

Please sign in to comment.