Skip to content

Commit

Permalink
Permit multiple lifetime bounds on parameter types.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Sep 16, 2014
1 parent a6d22fd commit 5e8d273
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions active/0049-bounds-on-object-and-generic-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,6 @@ declared:
Here, the constraint `T:'a` indicates that the data being iterated
over must live at least as long as the collection (logically enough).

### At most one explicit lifetime bound is permitted

For simplicity, we permit at most one *explicit* lifetime bound on any
given parameter type. That means that the following function is illegal:

fn foo<'a,'b,A:'a+'b>() { ... }

Remember that if there are multiple lifetime bounds, it implies that
all of them must hold. That means that if, in fact, `A` outlives both
`'a` and `'b` then either one of them is shorter than the other, the
two are the same, or there is a third lifetime that outlives them
both. Therefore, the function above can be rewritten as follows (using
explicit lifetime bounds, specified below):

fn foo<'a,'b,'c:'a+'b,A:'c>() { ... }

As far as I know, this situation has not arisen once in the codebase.

## Lifetime bounds on object types

Like parameters, all object types have a lifetime bound. Unlike
Expand All @@ -113,9 +95,9 @@ Here are some examples:
// IsStatic+'a 'static+'a
// IsStatic+Is<'a>+'b 'static,'a,'b

In general no object type is permitted to have zero bounds. Therefore,
if an object type with no derivable bounds appears, we will supply a
default lifetime using the normal rules:
Object types must have exactly one bound -- zero bounds is not
acceptable. Therefore, if an object type with no derivable bounds
appears, we will supply a default lifetime using the normal rules:

trait Writer { /* no derivable bounds */ }
struct Foo<'a> {
Expand Down

0 comments on commit 5e8d273

Please sign in to comment.