Skip to content

Commit a9775d0

Browse files
committed
add an extended example
1 parent 6d557ce commit a9775d0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

text/0000-infer-outlives.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,22 @@ get an error -- this is because, in that context, we will try to normalize
542542
the associated type reference, but we will fail in doing so because we do not
543543
have any where-clause stating that `T: 'a` (which the impl requires).
544544

545+
### Example 5: Multiple regions
546+
547+
Sometimes the outlives relationship can be inferred between multiple
548+
regions, not only type parameters. Consider the following:
549+
550+
```rust
551+
struct Foo<'a,'b,T> {
552+
x: &'a &'b T
553+
}
554+
```
555+
556+
Here the WF rules for the type `&'a &'b T` require that both:
557+
558+
- `'b: 'a` holds, because of the outer reference; and,
559+
- `T: 'b` holds, because of the inner reference.
560+
545561
# Drawbacks
546562
[drawbacks]: #drawbacks
547563

0 commit comments

Comments
 (0)