File tree 1 file changed +19
-8
lines changed
1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -362,9 +362,9 @@ struct Foo1 { x: &bool }
362
362
// ^ expected lifetime parameter
363
363
struct Foo2<'a> { x: &'a bool } // correct
364
364
365
- impl Foo2 { ... }
365
+ impl Foo2 {}
366
366
// ^ expected lifetime parameter
367
- impl<'a> Foo2<'a> { ... } // correct
367
+ impl<'a> Foo2<'a> {} // correct
368
368
369
369
struct Bar1 { x: Foo2 }
370
370
// ^^^^ expected lifetime parameter
@@ -777,21 +777,32 @@ struct Foo<'a> {
777
777
}
778
778
```
779
779
780
- Implementations need their own lifetime declarations:
780
+ Impl blocks declare lifetime parameters separately. You need to add lifetime
781
+ parameters to an impl block if you're implementing a type that has a lifetime
782
+ parameter of its own.
783
+ For example:
781
784
782
- ```
783
- // error, undeclared lifetime
785
+ ```compile_fail,E0261
786
+ // error, use of undeclared lifetime name `'a`
784
787
impl Foo<'a> {
785
- ...
788
+ fn foo<'a>(x: &'a str) {}
789
+ }
790
+
791
+ struct Foo<'a> {
792
+ x: &'a str,
786
793
}
787
794
```
788
795
789
- Which are declared like this:
796
+ This is fixed by declaring impl block like this:
790
797
791
798
```
792
799
// correct
793
800
impl<'a> Foo<'a> {
794
- ...
801
+ fn foo(x: &'a str) {}
802
+ }
803
+
804
+ struct Foo<'a> {
805
+ x: &'a str,
795
806
}
796
807
```
797
808
"## ,
You can’t perform that action at this time.
0 commit comments