summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/single_char_lifetime_names.txt
blob: 92dd24bf247ec7840cc58ba4cbf636fee230fcc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
### What it does
Checks for lifetimes with names which are one character
long.

### Why is this bad?
A single character is likely not enough to express the
purpose of a lifetime. Using a longer name can make code
easier to understand, especially for those who are new to
Rust.

### Known problems
Rust programmers and learning resources tend to use single
character lifetimes, so this lint is at odds with the
ecosystem at large. In addition, the lifetime's purpose may
be obvious or, rarely, expressible in one character.

### Example
```
struct DiagnosticCtx<'a> {
    source: &'a str,
}
```
Use instead:
```
struct DiagnosticCtx<'src> {
    source: &'src str,
}
```