Skip to content

Commit

Permalink
Merge pull request #1544 from Shark/impl-trait-typo
Browse files Browse the repository at this point in the history
Fix typo in Traits → "impl Trait"
  • Loading branch information
marioidival authored Jun 2, 2022
2 parents 8a90032 + 927ada3 commit dbb7e5e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/trait/impl_trait.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn parse_csv_document<R: std::io::BufRead>(src: R) -> std::io::Result<Vec<Vec<St
```

`parse_csv_document` is generic, allowing it to take any type which implements BufRead, such as `BufReader<File>` or `[u8]`,
but it's not important what type `R` is, and `R` is only used to declare the type of `src`, so the function can also be written an
but it's not important what type `R` is, and `R` is only used to declare the type of `src`, so the function can also be written as:

```rust,editable
fn parse_csv_document(src: impl std::io::BufRead) -> std::io::Result<Vec<Vec<String>>> {
Expand All @@ -46,7 +46,7 @@ fn parse_csv_document(src: impl std::io::BufRead) -> std::io::Result<Vec<Vec<Str
}
```

Note that using `impl Trait` as an argument type means that you cannot explicitly state what form of the function you use, i.e. `parse_csv_document::<std::io::Empty>(std::io::empty())` will not work with the second example
Note that using `impl Trait` as an argument type means that you cannot explicitly state what form of the function you use, i.e. `parse_csv_document::<std::io::Empty>(std::io::empty())` will not work with the second example.


## As a return type
Expand Down

0 comments on commit dbb7e5e

Please sign in to comment.