Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/tutorial/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ We'll need to capture the output somehow.
Rust's standard library has some neat abstractions
for dealing with I/O (input/output),
and we'll make use of one called [`std::io::Write`].
This is a [trait][trpl-traits] that abstracts over things we can write to,
which includes strings and `stdout`.
This [trait][trpl-traits] describes destinations for bytes,
including an in-memory `Vec<u8>` and `stdout`.

[trpl-traits]: https://doc.rust-lang.org/book/ch10-02-traits.html
[`std::io::Write`]: https://doc.rust-lang.org/1.39.0/std/io/trait.Write.html
Expand Down Expand Up @@ -204,10 +204,8 @@ to see a list of "Implementors".
With that knowledge,
let's change our function to accept a third parameter.
It can be any type that implements `Write`.
This way,
we can supply a simple string
in our tests
and make assertions on it.
In the test we can pass a mutable reference to a `Vec<u8>`
and compare the bytes written to it with a byte string literal.
Here is how we can write this version of `find_matches`:

```rust,ignore
Expand Down