]> git.lizzy.rs Git - rust.git/blob - src/docs/single_char_lifetime_names.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / single_char_lifetime_names.txt
1 ### What it does
2 Checks for lifetimes with names which are one character
3 long.
4
5 ### Why is this bad?
6 A single character is likely not enough to express the
7 purpose of a lifetime. Using a longer name can make code
8 easier to understand, especially for those who are new to
9 Rust.
10
11 ### Known problems
12 Rust programmers and learning resources tend to use single
13 character lifetimes, so this lint is at odds with the
14 ecosystem at large. In addition, the lifetime's purpose may
15 be obvious or, rarely, expressible in one character.
16
17 ### Example
18 ```
19 struct DiagnosticCtx<'a> {
20     source: &'a str,
21 }
22 ```
23 Use instead:
24 ```
25 struct DiagnosticCtx<'src> {
26     source: &'src str,
27 }
28 ```