Skip to content

Commit 8f828a3

Browse files
committed
Expand further on <> syntax in TRPL.
We haven't discussed this syntax yet, so provide a basic explanation and link up to later chapters. Fixes #26917
1 parent d034561 commit 8f828a3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/doc/trpl/lifetimes.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,18 @@ Before we get to that, though, let’s break the explicit example down:
7777
fn bar<'a>(...)
7878
```
7979

80-
This part declares our lifetimes. This says that `bar` has one lifetime, `'a`.
81-
If we had two reference parameters, it would look like this:
80+
We previously talked a little about [function syntax][functions], but we didn’t
81+
discuss the `<>`s after a function’s name. A function can have ‘generic
82+
parameters’ between the `<>`s, of which lifetimes are one kind. We’ll discuss
83+
other kinds of generics [later in the book][generics], but for now, let’s
84+
just focus on the lifteimes aspect.
85+
86+
[functions]: functions.html
87+
[generics]: generics.html
88+
89+
We use `<>` to declare our lifetimes. This says that `bar` has one lifetime,
90+
`'a`. If we had two reference parameters, it would look like this:
91+
8292

8393
```rust,ignore
8494
fn bar<'a, 'b>(...)

0 commit comments

Comments
 (0)