@@ -230,31 +230,7 @@ type MyStr<'a> = &'a str; //correct
230
230
231
231
Lifetime elision is a special, limited kind of inference for lifetimes in
232
232
function signatures which allows you to leave out lifetimes in certain cases.
233
- For example, the lifetimes on parameter in the following function signatures
234
- have been left out, but they still compile successfully:
235
-
236
- ```
237
- fn foo(x: &str) { }
238
-
239
- fn bar(x: &str, y: &str) { }
240
-
241
- fn baz(x: &str) -> &str { x }
242
- ```
243
-
244
- To explain the lifetime elision rules, we need to first discuss some background.
245
- The lifetime elision rules consider each lifetime in a function signature,
246
- whether it's elided or not, to be in a certain position, either *input
247
- position*, for function parameters, or *output position*, for the return type.
248
- For example, the function:
249
-
250
- ```
251
- fn hello<'a>(name: &'a str) -> (&'static str, &str) {
252
- ("hello", name)
253
- }
254
- ```
255
-
256
- has a signature with one lifetime in input position and two lifetimes in output
257
- position.
233
+ For more background on lifetime elision see [the book][book-le].
258
234
259
235
The lifetime elision rules require that any function signature with an elided
260
236
output lifetime must either have
@@ -279,6 +255,8 @@ fn bar(x: &str, y: &str) -> &str { ... }
279
255
// error, `y`'s lifetime is inferred to be distinct from `x`'s
280
256
fn baz<'a>(x: &'a str, y: &str) -> &str { ... }
281
257
```
258
+
259
+ [book-le]: http://doc.rust-lang.org/nightly/book/lifetimes.html#lifetime-elision
282
260
"## ,
283
261
284
262
E0107 : r##"
0 commit comments