Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove mention of try! in Display example #1357

Merged
merged 1 commit into from
Aug 8, 2020
Merged
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: 1 addition & 9 deletions src/hello/print/print_display/testcase_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ Using `?` on `write!` looks like this:
write!(f, "{}", value)?;
```

Alternatively, you can also use the `try!` macro, which works the same way.
This is a bit more verbose and no longer recommended, but you may still see it in
older Rust code. Using `try!` looks like this:

```rust,ignore
try!(write!(f, "{}", value));
```

With `?` available, implementing `fmt::Display` for a `Vec` is
straightforward:

Expand All @@ -42,7 +34,7 @@ impl fmt::Display for List {
// count in `count`.
for (count, v) in vec.iter().enumerate() {
// For every element except the first, add a comma.
// Use the ? operator, or try!, to return on errors.
// Use the ? operator to return on errors.
if count != 0 { write!(f, ", ")?; }
write!(f, "{}", v)?;
}
Expand Down