Skip to content

Commit

Permalink
Grammar fix in lifetime syntax (#208)
Browse files Browse the repository at this point in the history
I'm guessing there used to be two different reference examples here and one was removed, but now there's a subject-verb number mismatch. (Maybe the sentence should be rewritten entirely though.)
  • Loading branch information
timmc authored Sep 26, 2024
1 parent 308b9ed commit 70be670
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ch10-03-lifetime-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ which it can’t figure out lifetimes, the compiler will stop with an error.
These rules apply to `fn` definitions as well as `impl` blocks.

<!-- BEGIN INTERVENTION: d03748df-8dcf-4ec8-bd30-341927544665 -->
The first rule is that the compiler assigns a different lifetime parameter to each lifetime in each input type. References like `&'_ i32` needs a lifetime parameter, and structures like `ImportantExcerpt<'_>` need a lifetime parameter. For example:
The first rule is that the compiler assigns a different lifetime parameter to each lifetime in each input type. References like `&'_ i32` need a lifetime parameter, and structures like `ImportantExcerpt<'_>` need a lifetime parameter. For example:
* The function `fn foo(x: &i32)` would get one lifetime parameter and become `fn foo<'a>(x: &'a i32)`.
* The function `fn foo(x: &i32, y: &i32)` would get two lifetime parameters and become `fn foo<'a, 'b>(x: &'a i32, y: &'b i32)`.
* The function `fn foo(x: &ImportantExcerpt)` would get two lifetime parameters and become `fn foo<'a, 'b>(x: &'a ImportantExcerpt<'b>)`.
Expand Down

0 comments on commit 70be670

Please sign in to comment.